PHPMailer SMTP连接失败-GoDaddy [英] PHPMailer SMTP Connection Failed - GoDaddy

查看:105
本文介绍了PHPMailer SMTP连接失败-GoDaddy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个网站上工作,其中有一种表单,用于通过PHPMailer通过gmail发送电子邮件.

I am working on a website, and in it there is a form that is used to send email through gmail with PHPMailer.

我都正确设置了所有设置,因为它可以在我的AWS EC2服务器上运行.但是,当我在GoDaddy托管计划上使用完全相同的设置时,它不起作用(是的,我更改了需要"路径).

I have it all set up correctly, because it works on my AWS EC2 server. However, when I use the exact same setup on a GoDaddy hosting plan, it doesn't work (yes, I changed 'require' paths).

我收到此错误:

邮件错误:SMTP connect()失败.

Mailer Error: SMTP connect() failed.

这是我的代码:

$mail = new PHPMailer;

$mail->SMTPDebug = 0;

$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "**********@gmail.com";
$mail->Password = "*************";
$mail->SMTPSecure = "tls";
$mail->Port = 587;

$mail->setFrom("**********@gmail.com", "Red's Mailer");
$mail->addAddress("*********@shaw.ca", "Name");

$mail->isHTML = true;

$mail->Subject = "New Submission From " . $name;
$mail->Body = $html_msg;
$mail->AltBody = $alt_msg;

关于这个问题有什么想法吗?

Any ideas on the problem?

推荐答案

GoDaddy邮件服务器不支持任何包含aol,gmail,hotmail,yahoo,live,adim或msn的"FROM"标头条目的电子邮件.

GoDaddy mail server does not support any email containing "FROM" header entry of aol, gmail, hotmail, yahoo, live, aim or msn.

如果您正在使用linux cPanel托管计划,那么您确实需要在php代码中更改几行,它将起作用!

If you are using linux cPanel hosting plan then you do need to change few lines in your php code and it will work!

$mail = new PHPMailer;
$mail->SMTPDebug = 0;
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->ssl = false;
$mail->authentication = false;
$mail->addAddress("*********@shaw.ca", "Name");
$mail->isHTML = true;
$mail->Subject = "New Submission From " . $name;
$mail->Body = $html_msg;
$mail->AltBody = $alt_msg;

这篇关于PHPMailer SMTP连接失败-GoDaddy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆