【发布时间】:2017-02-21 18:44:23
【问题描述】:
我已将脚本复制到我的共享主机提供商并且它工作正常。我还在本地计算机上运行了脚本,它也可以工作。我认为值得一提的是电子邮件服务器来自共享主机提供商,而我的应用程序在 vps 上运行(我只更改了与通过网络浏览器连接到我的网站相关的 dns 记录)。
use PHPMailer;
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPDebug = 1;
$mail->Host = 'smtp.uhsevico.com';
$mail->SMTPAuth = true;
$mail->Username = "adm@mydomain.com.br";
$mail->Password = "mypassoword";
//$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('sender@mydomain.com.br', 'contato imotur');
mail->addAddress('receiver@yahoo.com', 'Diego Alves');
$mail->Subject = 'Here is the subject';
$mail->Body = "ImoTur no contato das atividades";
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
错误:
2017-02-21 18:30:03 SMTP 错误:无法连接到服务器:连接超时 (110) 2017-02-21 18:30:03 SMTP connect() 失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 无法发送邮件。邮件程序错误:SMTP 连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
【问题讨论】:
-
诊断这样的问题正是您忽略链接的故障排除指南中描述的内容。
-
在排除电子邮件发送故障之前,您如何希望从未编写过用于发送电子邮件的代码的人。故障排除指南对我来说太多了!