I am sending mails to two different persons, two different messages one for user and one for admin.
$message1='hello user'
$message2='hello admin'
$email = '[email protected]'
$adminemail = '[email protected]';
require 'PHPMailerAutoload.php';
$mail = new PHPMailer(true);
$mail->isHTML();
$mail->IsSMTP();
$mail->setFrom('[email protected]', 'admin site');
$mail->AddAddress( $email);
$mail->Subject = $subject;
$mail->Body =$message1;
$mail->Send();
//message for admin
$mail->Body =$message2;
//$adminemail = $generalsettings[0]["admin_email"];
$mail->AddAddress($adminemail);
$mail->Send();
But as a user I am receiving the message twice.. How to send two different messages to two different users.
// First Email $to = array( '[email protected]', '[email protected]',); $subject = "Subject"; $message = $message_start. $message_ONE. $message_end; sendMail(); // Second Email $to = array( '[email protected]', '[email protected]',); $subject = "Subject"; $message = $message_start.
PHPMailer does not set any limits, nor does the mail() function, it's only ISPs like GoDaddy that do. However, they do so by blocking access to normal SMTP ports, and/or redirecting SMTP connections to their own servers ( *.
PHPMailer can use a non-local mail server (SMTP) if you have authentication. Further advantages include: It can print various kinds of error messages in more than 40 languages when it fails to send an email. It has integrated SMTP protocol support and authentication over SSL and TLS.
PHPMailer doesn't create/use any SQL itself, nor does it have anything to do with javascript, so it's secure on those fronts.
You need to clear the recipients list before you add the new address for the second message. If you don't do that, the first recipient will receive the second message as well:
...
$mail->Body =$message1;
$mail->Send();
//message for admin
// Remove previous recipients
$mail->ClearAllRecipients();
// alternative in this case (only addresses, no cc, bcc):
// $mail->ClearAddresses();
$mail->Body =$message2;
//$adminemail = $generalsettings[0]["admin_email"];
// Add the admin address
$mail->AddAddress($adminemail);
$mail->Send();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With