[英]PHPMailer SMTP Connection Failed with Gmail o Domain - GoDaddy
I am working on a website with a form that is used to send email with PHPMailer. 我正在一个网站上使用用于通过PHPMailer发送电子邮件的表单。 i have a GoDaddy hosting plan linux.
我有一个GoDaddy托管计划linux。 I have tried multiple ways without any success, some time ago it worked and now does not work.
我曾经尝试过多种方法,但都没有成功,前段时间它起作用了,而现在却不起作用了。
Configuration 1 with Gmail Gmail的配置1
include_once('phpmailer/class.phpmailer.php');
include_once('phpmailer/class.smtp.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = false;
$mail->SMTPSecure = false; (I've tried the 2 options)
$mail->Host = "relay-hosting.secureserver.net";
$mail->Port = 25;
$mail->Username ='xxxx@gmail.com';
$mail->Password = 'xxxxxxx';
$mail->Subject = 'Form from website';
$mail->AddAddress("xxxxx@xxxx.com");
$mail->FromName = "formsite";
$mail->SMTPDebug = 3;
$mail->Debugoutput = 'html';
Log 日志
Connection: opening to relay-hosting.secureserver.net:25, timeout=300, options=array ()
连接:打开relay-hosting.secureserver.net:25,超时= 300,选项= array()
SMTP ERROR: Failed to connect to server: Connection refused (111) SMTP connect() failed.
SMTP错误:无法连接到服务器:连接被拒绝(111)SMTP connect()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Configuration 2 email from the same domain 来自同一域的配置2电子邮件
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPSecure = true; // Enable TLS encryption, `ssl` also accepted
$mail->SMTPAuth = false; // Enable SMTP authentication
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->Host = 'p3plcpnxxx.prod.phx3.secureserver.net';
$mail->Port = 465;
$mail->Username ='noreply@samedomain.com';
$mail->Password = 'xxxxxxxx';
$mail->Subject = 'Form from website';
$mail->AddAddress("xxxxx@xxxx.com");
$mail->FromName = "formsite";
$mail->SMTPDebug = 3;
$mail->Debugoutput = 'html';
Log 日志
SERVER -> CLIENT: 220-p3plcpnxxxx.prod.phx3.secureserver.net ESMTP Exim 4.89 #1 Thu, 14 Dec 2017 21:11:11 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
服务器->客户:220-p3plcpnxxxx.prod.phx3.secureserver.net ESMTP Exim 4.89#1 Thu,14 Dec 2017 21:11:11 -0700 220-我们未授权使用此系统传输未经请求的220和/或批量电子邮件。
CLIENT -> SERVER: EHLO www.xxxxxx.com
客户->服务器:EHLO www.xxxxxx.com
SERVER -> CLIENT: 250-p3plcpnxxxx.prod.phx3.secureserver.net Hello p3plcpnxxxx.prod.phx3.secureserver.net [180.168.200.196]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-CHUNKING250 HELP
服务器->客户端:250-p3plcpnxxxx.prod.phx3.secureserver.net您好p3plcpnxxxx.prod.phx3.secureserver.net [180.168.200.196] 250尺寸52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-CHUNKING250帮助
To help others struggling with GoDaddy, these two variations worked for me: 为了帮助其他人在GoDaddy上苦苦挣扎,以下两种变体对我有用:
Hosting: GoDaddy shared/cPanel 托管:GoDaddy共享/ cPanel
Sending "From:" a GMail address 发送“发件人:” GMail地址
PHPMailer version 6.0.5 PHPMailer版本6.0.5
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$send_using_config = 1; // set to 1, 2, etc. to test different settings
switch ($send_using_config):
case 1:
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPSecure = FALSE;
$mail->SMTPAuth = FALSE;
$mail->SMTPAutoTLS = FALSE;
break;
case 2:
# Host amnd Port info obtained from:
# Godaddy > cPanel Home > Email > cPanel Email > Mail Configuration > "Secure SSL/TLS Settings" > Outgoing Server
$mail->Host = 'a2plcpnxyzw.prod.iad2.secureserver.net';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = FALSE;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => FALSE,
'verify_peer_name' => FALSE,
'allow_self_signed' => TRUE
)
);
break;
endswitch;
$mail->Username = 'you@gmail.com';
$mail->Password = 'your_gmail_password';
$mail->setFrom($from);
$mail->addAddress($to);
$mail->Subject = $subject;
$mail->msgHTML($message);
$mail->send();
These settings are based on the question posted here and modified with the advice from @Synchro on StackOverflow and GitHub. 这些设置基于此处发布的问题,并根据StackOverflow和GitHub上@Synchro的建议进行了修改。 Thank you @Synchro!
谢谢@Synchro!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.