Phpmailer failed to send emails cyclically. This post was last edited by an5464684 from 2013-12-2718: 20: 21 using phpmailer. the account and password are correct and passed the test. 1. if the message is sent successfully, the phpmailer loop fails to send the email.
At the end of this post, phpmailer was edited and used by an5464684 at 18:20:21 on. the account and password were correct and the test passed.
1. a single message is sent successfully.
2. However, when writing a circular email, only the first sending is successful, and all subsequent sending Fails. check the Log that cocould not authenticate has not passed the verification.
Why?
try
{
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPDebug = 0;
$mail->Host = "smtp.126.com"; // specify main and backup server
$mail->Port = 25;
$mail->Username = "sent@126.com"; // SMTP username
$mail->Password = "******"; // SMTP password
$mail->From = $mail->Username;
$mail->FromName = "myname";
$mail->AddAddress("receive@163.com", "toname");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body in bold!";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Mailer Error: ".$mail->ErrorInfo;
return false;
}
else
{
return true;
}
} catch (phpmailerException $e)
{
echo "Send mail failed: ".$e->errorMessage();
return false;
}
------ Solution --------------------
If a single success is successful, the program will be okay, because you are using 126 of the email server, and it will certainly not allow you to repeatedly send emails, so you can send another email and let the program sleep for a few seconds.
------ Solution --------------------
Generally, emails like qq, 163, and 126 won't allow you to send them continuously. if you want to send them cyclically, you can sleep for several seconds, however, every time an email is sent to sleep for a few seconds, the efficiency is certainly not high. you can also send it to multiple users at the same time, and then sleep for several seconds.
------ Solution --------------------
Set_time_limit (0 );
Ini_set ("maid", "18000000 ");
Include 'phpmailer/class. PHPMailer. php ';
$ Sendmail = ''; // recipient
$ Title = 'I want to mail ';
$ Remark = 'This is the Mail content ';
$ Mailer = new PHPMailer ();
$ Mailer-> CharSet = "UTF-8 ";
$ Mailer-> ContentType = 'text/html ';
$ Mailer-> IsSMTP ();
$ Mailer-> SMTPDebug = 0;
$ Mailer-> SMTPAuth = true;
$ Mailer-> SMTPSecure = 'SSL ';
$ Mailer-> Host = 'smtp .163.com ';
$ Mailer-> Port = '000000 ';
$ Mailer-> Username = ''; // sender's email address
$ Mailer-> Password = 'XXX'; // The sender's Password.
$ Mailer-> SetFrom ('','');
$ Mailer-> AddAddress ($ sendmail );
$ Mailer-> Subject = $ title;
$ Mailer-> MsgHTML ($ remark );
For ($ I = 0; $ I <10; $ I ++ ){
$ Mailer-> send ();
Sleep (3 );
}
?>
I have tried it.
------ Solution --------------------
Close once after each sending.
View the phpmailer attributes.
Use the Smtpclose (); method.