Jump to content

Recommended Posts

Why are my posts getting booted...? I just need help!!!

 

Can someone help me getting multiple emails sent with PHP? I was able to get this to work with 1 recepient at a time, but not multiple. The other code on the forums I have not been able to get to work... can someone help with the below code?

 

 

Many thanks

 

 

 

function sentEmailSMTP2($email1, $email2)

{

 

 

$string2 = $email1. "@hotmail.com" . "," . $email2. "@hotmail.com";

 

$to = $string2;

$from = "me@xxxxxxxxx.com";

$subject = 'messageX';

$message = 'Its ready';

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

 

 

$host = "mail.xxxxxxx.com";

$username = "me@xxxxxxxx.com";

$password = "password";

$mail = new PHPMailer();

 

 

$mail -> IsSMTP();

// telling the class to use SMTP

$mail -> SMTPAuth = true;

$mail -> SMTPKeepAlive = true;

$mail -> Host = $host;

$mail -> Username = $username;

$mail -> Password = $password;

$mail -> SetFrom($from, 'Test ');

$mail -> Subject = $subject;

 

 

$mail -> AddAddress($string2);

 

 

$mail -> Body = $message;

if (!$mail -> Send())

{

echo "Mailer Error (" . str_replace("@", "@", $string2) . ') ' . $mail -> ErrorInfo . '<br />';

}

else

{

echo "Message sent to :" . $string2 . ' (' . str_replace("@", "@", $string2) . ')<br />';

}

 

}

Link to comment
https://forums.phpfreaks.com/topic/271019-php-mailer-to-multiple-addresses-issue/
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.