I want to send an email to multiple email address with different information in them. This code work for the auto response, but how do I include other email recipients.

include "config.php";

// DO NOT EDIT BELOW THIS LINE, UNLESS YOU KNOW WHAT YOU ARE DOING
if ($username == "" or $userpass == "" or $useremail == ""){$msg3=true;}

$email = $useremail; 
if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $email)) {
   $msg4 = true; $pass = "no"; }
if (!isset($useremail)) 
echo "Error, Please re-send $username" ;

$todayis = date("l, F j, Y, g:i a") ;

$subject = "Registration";

$message = " $todayis [EST]
User Name -  $username
User Email - $useremail

From: $sendersName

Your user level will be set upon approval
This email was sent by an auto responder, you cannot reply to this email.

";

$from = "From: $sendersEmail";


if ($email != "") 
mail($email, $subject, $message, $from);

Also how do I move From: $sendersName above the $todayis = date("l, F j, Y, g:i a") ; without getting errors.

    Couldnt you just use an array and go through the array of emails?

      I dont know how I just want to do the simplest way

        // multiple recipients
        $to  = 'aidan@example.com' . ', '; // note the comma
        $to .= 'wez@example.com';
        

        also... sending mail FROM $sendersEmail is going to get you in trouble with any mail server that scans for forged envelopes... mail should always be sent from an email address on your mail domain (e.g. no-reply@yourdomain.com), include the senders email in the body and set a Reply-To header to be the $sendersEmail

        $headers = 'From: no-reply@yourdomain.com' . "\r\n" .
            'Reply-To: '.$sendersEmail.''. "\r\n" .
            'X-Mailer: PHP/' . phpversion();
        

        FYI this all took me 2 seconds to look up on the mail() man-page

          How do I incorporate this into the code I have, I guess is my problem.

          scrupul0us;10904316 wrote:
          // multiple recipients
          $to  = 'aidan@example.com' . ', '; // note the comma
          $to .= 'wez@example.com';
          

          also... sending mail FROM $sendersEmail is going to get you in trouble with any mail server that scans for forged envelopes... mail should always be sent from an email address on your mail domain (e.g. no-reply@yourdomain.com), include the senders email in the body and set a Reply-To header to be the $sendersEmail

          $headers = 'From: no-reply@yourdomain.com' . "\r\n" .
              'Reply-To: '.$sendersEmail.''. "\r\n" .
              'X-Mailer: PHP/' . phpversion();
          

          FYI this all took me 2 seconds to look up on the mail() man-page

            Please help, I looked a mail tuts for 4hours and I dont understand how to incorporate adding more than one email address in the script. Ive tried the before mentioned with no luck and the last post mentioned some problems I would have with current script. I would like to go that way so not to have problems, but I dont know how.

              Write a Reply...