我在电子邮件和 Office 下使用 GoDaddy 专业电子邮件(不是工作区电子邮件)。对于我的网站,我想使用 PHPMailer 向用户发送电子邮件。我已根据 GoDaddy 电子邮件服务器信息使用了所有凭据。
根据 GoDaddy 的说法,发送服务器设置为:
- SMTP 主机:'smtpout.secureserver.net'
- 端口:465
- 安全:'ssl'
我的 PHPMailer 代码设置如下:
<?php
try
{
$email = new PHPMailer(TRUE);
$email->isSMTP();
$email->SMTPDebug = 2;
$email->SMTPAuth = TRUE;
$email->SMTPAutoTLS = FALSE;
$email->SMTPSecure = "ssl";
$email->Host = "smtpout.secureserver.net";
$email->Port = 465;
$email->Username = "myUserName";
$email->Password = "MyPassword";
$email->setFrom("[email protected] /cdn-cgi/l/email-protection", "Name");
$email->addAddress("[email protected] /cdn-cgi/l/email-protection", "Name");
$email->isHTML(TRUE);
$email->Body = "My HTML Code";
$email->Subject = "My Subject";
$email->send();
}
catch (Exception $e)
{
// $email->ErrorInfo;
}
?>
上面的代码抛出以下错误:
2019-08-14 10:55:58 SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
我已经寻找解决方案。一些 Stackoverflow 问题讨论了有关 GoDaddy Workspace 电子邮件的问题。但到目前为止,我对找到解决方案感到沮丧。如果我做错了什么,请帮助我。
我发现以下设置有效。这可能有用。
使用80作为端口
<?php
try
{
$email = new PHPMailer(TRUE);
$email->isSMTP();
$email->SMTPDebug = 2;
$email->SMTPAuth = TRUE;
$email->SMTPAutoTLS = FALSE;
$email->SMTPSecure = "tls";
$email->Host = "smtpout.secureserver.net";
$email->Port = 80;
$email->Username = "GoDaddy Professional Email Username";
$email->Password = "GoDaddy Professional Email Password";
$email->setFrom("[email protected] /cdn-cgi/l/email-protection", "Name");
$email->addAddress("[email protected] /cdn-cgi/l/email-protection", "Name");
$email->isHTML(TRUE);
$email->Body = "My HTML Code";
$email->Subject = "My Subject";
$email->send();
}
catch (Exception $e)
{
// $email->ErrorInfo;
}
?>`
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)