Emailing Multiple Email Addresses

6 posts by 2 authors in: Forums > CMS Builder
Last Post: October 6, 2014   (RSS)

By nmsinc - October 2, 2014

I have a need to mail multiple email address and having some problems - any suggestions would be appreciated:

Thanks - nmsinc

$allemails = ray@abc.com; kim@abccom.com; bill@abccom.com;
 
                      $mailArray99 = array( 
                      'to'      => $allemails,
                      'from'    => $CURRENT_USER['email'],
                      'subject' => $_REQUEST['subject'],
                      'html'    => $content 
                      ); 
                      $mailErrors99   = sendMessage($mailArray99);
                      if ($mailErrors99) {die("Mail Error #99: $mailErrors99"); }


nmsinc

By claire - October 2, 2014

Emails should be in quotes and comma separated, like so:

$allemails = "ray@abc.com, kim@abccom.com, bill@abccom.com";
 
                      $mailArray99 = array( 
                      'to'      => $allemails,
                      'from'    => $CURRENT_USER['email'],
                      'subject' => $_REQUEST['subject'],
                      'html'    => $content 
                      ); 
                      $mailErrors99   = sendMessage($mailArray99);
                      if ($mailErrors99) {die("Mail Error #99: $mailErrors99"); }

Assuming you're using the usual PHP mail function, at least. But either way the lack of quotes will cause errors there.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - October 2, 2014

Hi Claire,

How about when the emails are passed via a form submit where the user enters ray@abc.com, kim@abc.com, bill@abc.com into a form box?

The attempt returns invalid email address!

Thanks - nmsinc

nmsinc

By nmsinc - October 4, 2014

Hi Clair,

Please check over the code below - I receive zero errors, however; no emails are being processed by the script. I have tried both "implode" and "explode" with no luck!

Any ideas?

Thanks - nmsinc

                      if ($_REQUEST['extra_emails']) {
                      $recipients = array( $_REQUEST['extra_emails'] );
                      $address = explode(',', $recipients); // email address
                      foreach ($address as $value) {
                      $mailArray99 = array( 
                      'to'      => $value,
                      'from'    => $CURRENT_USER['email'],
                      'subject' => $_REQUEST['subject'],
                      'html'    => $content 
                      ); 
                      $mailErrors99   = sendMessage($mailArray99);
                      if ($mailErrors99) {die("Mail Error #99: $mailErrors99"); }
                      }
                      }

nmsinc

By claire - October 6, 2014

Are you sure that the IF check at the start is being processed?

At this point, I usually drop echo statements into the code at various points to make sure that the script is actually getting to the code as expected.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/