Recently using Phpmailer library to connect NetEase's smtp.126.com mail service send mail always return connection failed
Mailer Error: SMTP connect() failed.
The same is true for the Swiftmailer library.
This is the use of the new NetEase account will have problems, because the new NetEase account needs to open the client authorization code to use the SMTP service. The old account is not the problem.
How do I use this authorization code to connect with the SMTP of NetEase? Or are there other ways to troubleshoot connection failures?
/**这是网上摘抄的代码 使用其他帐号可以正常使用的,问题同上*//*** phpmailer发送邮件实例* 发送网易邮箱126.com* edit www.jbxue.com*/$mail= new PHPMailer();$body= "发送邮件成功";//采用SMTP发送邮件$mail->IsSMTP();//邮件服务器$mail->Host = "smtp.126.com";$mail->SMTPDebug = 0;//使用SMPT验证$mail->SMTPAuth = true;//SMTP验证的用户名称$mail->Username = "longmonhau";//SMTP验证的秘密$mail->Password = "?";//密码//设置编码格式$mail->CharSet = "utf-8";//设置主题$mail->Subject = "测试";//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";//设置发送者$mail->SetFrom('longmonhau@126.com', 'test');//采用html格式发送邮件$mail->MsgHTML($body);//接受者邮件名称$mail->AddAddress("1307995200@qq.com", "test");//发送邮件if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo;} else { echo "Message sent!";}
Reply content:
Recently using Phpmailer library to connect NetEase's smtp.126.com mail service send mail always return connection failed
Mailer Error: SMTP connect() failed.
The same is true for the Swiftmailer library.
This is the use of the new NetEase account will have problems, because the new NetEase account needs to open the client authorization code to use the SMTP service. The old account is not the problem.
How do I use this authorization code to connect with the SMTP of NetEase? Or are there other ways to troubleshoot connection failures?
/**这是网上摘抄的代码 使用其他帐号可以正常使用的,问题同上*//*** phpmailer发送邮件实例* 发送网易邮箱126.com* edit www.jbxue.com*/$mail= new PHPMailer();$body= "发送邮件成功";//采用SMTP发送邮件$mail->IsSMTP();//邮件服务器$mail->Host = "smtp.126.com";$mail->SMTPDebug = 0;//使用SMPT验证$mail->SMTPAuth = true;//SMTP验证的用户名称$mail->Username = "longmonhau";//SMTP验证的秘密$mail->Password = "?";//密码//设置编码格式$mail->CharSet = "utf-8";//设置主题$mail->Subject = "测试";//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";//设置发送者$mail->SetFrom('longmonhau@126.com', 'test');//采用html格式发送邮件$mail->MsgHTML($body);//接受者邮件名称$mail->AddAddress("1307995200@qq.com", "test");//发送邮件if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo;} else { echo "Message sent!";}
In my opinion, the client authorization code is like an alternative to a password.
Reference Link: http://help.163.com/14/0923/22/A6S1FMJD00754KNP.html