Phpmailer Loop Sending message failed
This post was last edited by an5464684 on 2013-12-27 18:20:21
Use Phpmailer, account and password are correct, and test pass.
1. Single send will succeed
2. However, when writing a cyclic email, only the first successful send, the subsequent send failed, check the log display: Could not authenticate, verify that failed.
What is the reason for this?
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 = "[email protected]"; SMTP username
$mail->password = "******"; SMTP Password
$mail->from = $mail->username;
$mail->fromname = "MyName";
$mail->addaddress ("[Email protected]", "toname");
$mail->wordwrap = 50; Set word wrap to characters
$mail->ishtml (TRUE); Set email format to HTML
$mail->subject = "Here is the Subject";
$mail->body = "This is the HTML message BodyIn bold!";
$mail->altbody = "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--------------------
A single success of the program is not a problem, because you are using 126 of the mail server that it will certainly not let you uninterrupted loop sent, so you can send the completion of a letter after the program sleep for a few seconds
------Solution--------------------
In general, such as QQ, 163, 126 and other mailboxes, they will not allow you to send continuously, so if you want to loop to send, you can sleep a few seconds, but each send a message sleep a few seconds, the efficiency is not high, can also be sent to multiple users, and then sleep a few seconds
------Solution--------------------
Set_time_limit (0);
Ini_set ("Max_execution_time", "18000000");
Include ' phpmailer/class.phpmailer.php ';
$sendmail = ";//Recipient
$title = ' I want to send mail ';
$remark = ' This is the message 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 = ' 465 ';
$mailer->username = ';//Sender's mailbox
$mailer->password = ' xxx ';//Sender Password
$mailer->setfrom (', ');
$mailer->addaddress ($sendmail);
$mailer->subject = $title;
$mailer->msghtml ($remark);
for ($i = 0; $i < $i + +) {
$mailer->send ();
Sleep (3);
}
?>
I've tried it without a problem.
------Solution--------------------
Once each send, close one time.
View the Phpmailer property.
Using the Smtpclose () method is possible.