PHPMailer: Using remote SMTP server, works under localhost, Connection refused (111) on remote server(PHPMailer:使用远程 SMTP 服务器,在本地主机下工作,远程服务器上的连接被拒绝(111))
问题描述
我在这里遇到了一个奇怪的问题.我正在尝试使用 PHPMailer 通过 SMTP 发送电子邮件.我有一个由 GoDaddy 托管的网站,我正在尝试使用该 SMTP 帐户发送邮件.
I've got a bizarre problem here. I'm trying to use PHPMailer to send an email, through SMTP. I have a website hosted by GoDaddy and it's that SMTP account that I'm trying to use to send the mail.
- 如果我在本地服务器上执行我的 PHP 文件,它会起作用.
- 如果我在 GoDaddy 的服务器上执行我的 PHP 文件,它不起作用.
我得到的错误信息是:
SMTP ->错误:无法连接到服务器:连接被拒绝(111)
我检查了本地主机和远程服务器上的 phpinfo
.两者都将 smtp_port
列为 25
.我在我的机器上使用 WAMP,服务器是某种形式的 Linux(我对此一无所知,也不知道如何管理).
I checked phpinfo
on both localhost and the remote server. Both have smtp_port
listed as 25
. I'm using WAMP on my machine and the server is some form of Linux (which I know nothing about and have no idea how to administer).
这里是有问题的代码:
INDEX.PHP:
<?php
date_default_timezone_set('America/Los_Angeles');
include_once("phpmailer/class.phpmailer.php");
$mail = new PHPMailer;
$mail->SMTPDebug = 1;
$mail->Port = 25;
$mail->IsSMTP();
$mail->Host = 'smtpout.secureserver.net';
$mail->SMTPAuth = true;
$mail->Username = 'username@site.com';
$mail->Password = 'super_secret_password';
$mail->SMTPSecure = ''; // tried ssl and tls, with same result
$mail->ClearAddresses();
$mail->AddAddress('receiver@hotmail.com', 'Receiver Name');
$mail->From = "username@site.com";
$mail->FromName = "Username";
$mail->Subject = 'Hi there';
$mail->Body = "This is a message";
if ($mail->Send()) {
echo "Message sent!
";
}
else {
echo "Message failed!
";
print_r($mail->ErrorInfo);
}
exit();
?>
推荐答案
我觉得你应该分两步1)按照godaddy支持http://support.godaddy.com/help/article/319/what-do-i-do-if-i-have-trouble-connecting-to-my-电子邮件帐户2)使用relay-hosting.secureserver.net"作为您的主机,而不是smtpout.secureserver.net"
I think you should perform two step 1) check your port as suggested on godaddy support http://support.godaddy.com/help/article/319/what-do-i-do-if-i-have-trouble-connecting-to-my-email-account 2)use "relay-hosting.secureserver.net" as your host instead of "smtpout.secureserver.net"
GoDaddy 确实允许使用 Gmail 作为您的 SMTP 发送电子邮件,只需摆脱 smtp.gmail.com 并改用其主机即可.这是我的设置:
GoDaddy does allow to send emails using Gmail as your SMTP, just need to get rid of the smtp.gmail.com and use their Host instead. This is my setup:
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = "relay-hosting.secureserver.net";
$mail->Username = "your-account@gmail.com";
$mail->Password = "yourpassword";
// ...
// send from, send to, body, etc...
参考(见前两篇文章)http://support.godaddy.com/groups/web-hosting/forum/topic/phpmailer-with-godaddy-smtp-email-server-script-working/
这篇关于PHPMailer:使用远程 SMTP 服务器,在本地主机下工作,远程服务器上的连接被拒绝(111)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHPMailer:使用远程 SMTP 服务器,在本地主机下工作,远程服务器上的连接被拒绝(111)
基础教程推荐
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01