Today I had to fix a script that sends an e-mail using PHPMailer. Here is the intital code:
$mail->From = "email@example.com"; $mail->FromName = "Lampdocs.com"; $mail->AddAddress("firstname.lastname@example.org"); $mail->AddReplyTo($webmaster_email, "Lampdocs.com"); $mail->WordWrap = 70; // set word wrap $mail->IsHTML(true); // send as HTML $mail->Subject = "Order from New Paypal Address"; $mail->Body = $milo; //HTML Body $mail->Send();
I had to send 2 different mails: one to the buyer and another one to administrator. If I tried to send another mail by using the same code, I got 2 recipients for e-mail. I’ve searched for the way in documentation, but the best way was to check the code of the class itself. Here is the string you should add before sending the next e-mail:
This will clear all arrays with recipients. You can now send another e-mail, specifying your next recipient and a copy will not be sent to the first one.