我的PHP脚本无法在我的vps上发送电子邮件(使用PHPMailer)

时间:2017-02-21 18:44:23

标签: php smtp phpmailer vps

我已将脚本复制到我的共享主机提供商,但它确实有效。我也在我的本地计算机上运行脚本,它也有效。我认为值得一提的是电子邮件服务器来自共享主机提供商,我的应用程序运行在vps上(我只更改了与通过Web浏览器连接到我的网站相关的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 ERROR:无法连接到服务器:连接超时(110)2017-02-21 18:30:03 SMTP connect()失败。无法发送https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting消息.Mailer错误:SMTP connect()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

1 个答案:

答案 0 :(得分:0)

当我收到大学VPS邮件时,我遇到了类似的问题。他们有特定的配置,所有外发邮件都必须转发到。我在自己的VPS上安装了自己的邮件服务器,然后更改了配置,以便将所有邮件发送到大学服务器。我会联系您的托管服务提供商,看看他们是否在您的VPS上有一些特定的配置。