我的 php 脚本无法在我的 vps 上发送电子邮件(使用 PHPMailer)
My php script is unable to send email on my vps (using PHPMailer)
我已将脚本复制到我的共享主机提供商并且它有效。我也在我的本地计算机中 运行 脚本,它也有效。我认为值得一提的是电子邮件服务器来自共享主机提供商,我的应用程序是 运行 在 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 Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
我在大学收到邮件时遇到了类似的问题VPS。他们有特定的配置,所有外发邮件都必须转发到那里。我在 VPS 上安装了自己的邮件服务器,然后更改了配置,以便所有邮件都发送到大学服务器。我会联系您的托管服务提供商,看看他们是否有您在 VPS.
上需要的一些特定配置
我已将脚本复制到我的共享主机提供商并且它有效。我也在我的本地计算机中 运行 脚本,它也有效。我认为值得一提的是电子邮件服务器来自共享主机提供商,我的应用程序是 运行 在 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 Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
我在大学收到邮件时遇到了类似的问题VPS。他们有特定的配置,所有外发邮件都必须转发到那里。我在 VPS 上安装了自己的邮件服务器,然后更改了配置,以便所有邮件都发送到大学服务器。我会联系您的托管服务提供商,看看他们是否有您在 VPS.
上需要的一些特定配置