我正在使用一个用于通过PHPMailer发送电子邮件的表单的网站上工作。我有一个GoDaddy托管计划linux。我尝试了多种方法但没有取得任何成功,前段时间它起作用,但现在不起作用。
使用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';
日志
连接:打开到relay-hosting.secureserver.net:25,timeout = 300,options = array()
SMTP错误:无法连接到服务器:连接被拒绝(111) SMTP connect()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
来自同一域的配置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';
日志
服务器 - >客户:220-p3plcpnxxxx.prod.phx3.secureserver.net ESMTP Exim 4.89#1 Thu,14 Dec 2017 21:11:11 -0700 220-我们不授权使用此系统来运输未经请求的,220和/或批量电子邮件。
客户 - >服务器:EHLO www.xxxxxx.com
服务器 - >客户:250-p3plcpnxxxx.prod.phx3.secureserver.net您好 p3plcpnxxxx.prod.phx3.secureserver.net [180.168.200.196] 250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-CHUNKING250帮助
答案 0 :(得分:1)
为了帮助其他人在GoDaddy上苦苦挣扎,以下两种变体对我有用:
托管:GoDaddy共享/ cPanel
发送“发件人:” GMail地址
PHPMailer版本6.0.5
ResourceId
这些设置基于此处发布的问题,并通过StackOverflow和GitHub上@Synchro的建议进行了修改。谢谢@Synchro!