Hi

I'd like to send one email to the registered user and a seperate email to the Administrator, with a separate body.
I thought I could just duplicate the mail() but now neither email is being sent.

Email 1 - Activation Email to the Registered User

$to      = "liz.banbury@gmail.com, ".$reg_email;
            $subject = 'Bright-Tutors - Registration Confirmation';
            $msg =  "Welcome to our website!\r\rYou, or someone using your email address, has completed registration at bright-tutors.com. \n" . 
            "You can complete registration by clicking the following  link:\rhttp://www.bright-tutors.com/verify.php?$activationKey\r\r \n" .
            "If this is an error, ignore this email and you will be removed from our mailing list. \n" .
            "Regards,\n Bright-Tutors.com Team \n" . 
            "------------------------------------------------------------\n" .
            "Please take note of your registered username and password and keep them safely.\n" .
            "------------------------------------------------------------\n" .
            "Registered Username: $username\n" .
            "Registered Password: $password1";

            $headers = 'From: admin@xxxxxxxx.com,$reg_email' . "\r\n" .
            'Reply-To: $reg_email' . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
            mail($to, $subject, $msg, $headers);

Email 2 - To the Administrator:

$to2      = "liz.banbury@gmail.com, admin@xxxxxxx.com";
            $subject2 = 'Bright-Tutors - Registration Confirmation';
            $msg2 =  "$reg_name has completed registration at bright-tutors.com. \n" . 
            "Please contact them at: " .$reg_email;

            $headers = 'From: admin@xxxxxxx.com,$reg_email' . "\r\n" .
            'Reply-To: $reg_email' . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
            mail($to2, $subject2, $msg2, $headers);

Any help would be great thanks.

Recommended Answers

All 4 Replies

Hi, try to remove the white spaces between the addresses in the destination variables $to and $to2, so these:

$to      = "email@gmail.com, ".$reg_email;
$to2     = "email@gmail.com, admin@xxxxxxx.com";

Should be:

$to      = "email@gmail.com,".$reg_email;
$to2     = "email@gmail.com,admin@xxxxxxx.com";

Have you tried to send each one separately ?

Hi Yes, separately works.

Hi yes removing the white space helped. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.