【问题标题】:My php script is unable to send email on my vps (using PHPMailer)我的 php 脚本无法在我的 vps 上发送电子邮件(使用 PHPMailer)
【发布时间】: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

【问题讨论】:

  • 诊断这样的问题正是您忽略链接的故障排除指南中描述的内容。
  • 在排除电子邮件发送故障之前,您如何希望从未编写过用于发送电子邮件的代码的人。故障排除指南对我来说太多了!

标签: php smtp phpmailer vps


【解决方案1】:

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

【讨论】:

  • 哦,是的!经过两天修改我的代码并责备自己后,我发现我的 vps 为新帐户或显示可疑行为或类似行为的帐户阻止了端口 587!
  • 你给我指明了正确的方向。我永远不会猜到它是托管服务提供商。
  • 很高兴你知道了!
  • 如果您阅读了故障排除指南,您可能已经猜到这是您的托管服务提供商,因为这正是它对您所看到的错误的解释......
猜你喜欢
  • 1970-01-01
  • 2015-09-06
  • 2020-11-25
  • 2012-08-02
  • 2019-01-19
  • 2023-03-20
  • 2017-07-19
  • 2017-10-05
  • 1970-01-01
相关资源
最近更新 更多