SMTP错误:无法连接到服务器:连接被拒绝(111)错误消息 [英] SMTP ERROR: Failed to connect to server: Connection refused (111) ERROR MESSAGE

查看:1298
本文介绍了SMTP错误:无法连接到服务器:连接被拒绝(111)错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 PHPMailer 的新手,我刚刚使用 Composer 下载了它,并将其编码为index.php:

I'm new to PHPMailer, and I just downloaded it with Composer and coded this as index.php:

    <?php 
require_once 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
$m = new PHPMailer;
$m->isSMTP();
$m->SMTPAuth = true;
$m->SMTPDebug = 2;

$m->Host = 'smtp.mail.yahoo.com';
$m->Username = 'vagefipooya@yahoo.com';
$m->Password = 'MY PASSWORD';
$m->SMTPSecure = 'ssl';
$m->Port = 465;
$m->IsHTML(true);

$m->SetFrom('pouyavey@gmail.com');
$m->FromName = 'Pouya Vaghefi';
$m->addReplyTo('pouyavey@gmail.com','Pouya Vey');
$m->addAddress('pouyavey@gmail.com','Pouya Vey');
//$m->addCC('alex@phpacademy','Alex Garret');
//$m->addBCC('alex@phpacademy','Alex Garret');
$m->CharSet = "UTF-8";

$m->Subject = 'Here is an email';
$m->msgHTML("convert HTML into a basic plain-text alternative body");
$m->Body = 'This is the body of an email';
$m->AltBody = 'This is the body of an email';

if (!$m->send()) {
        echo "Mailer Error: " . $m->ErrorInfo;
    } else {
        echo "Message sent!";
    }
    ?>

然后我将其上传到正在使用 cPanel 的站点(我的站点未使用ssl),并尝试加载页面,但出现此错误:

Then I uploaded it to my site (my site does not use ssl) which is using cPanel and tried to load the page but I got this as error:

2018-04-19 10:03:46 SMTP错误:无法连接到服务器:连接被拒绝(111) SMTP connect()失败. /wiki/问题排查 邮件错误:SMTP connect()失败.

2018-04-19 10:03:46 SMTP ERROR: Failed to connect to server: Connection refused (111) SMTP connect() failed. /wiki/Troubleshooting Mailer Error: SMTP connect() failed.

我也阅读了有关此问题的相关问题,并将端口从465更改为587(带tls),25和26,但仍无法解决问题.

I also read the related questions to this problem and changed the port from 465 to 587 (with tls), 25 and 26 but couldn't solve the problem yet.

所以您能帮我解决这个错误,因为我真的不知道该怎么办!

So can you please help me with this error, cause I really don't know what to do!

谢谢...

推荐答案

这主要是由于您的托管服务提供商的防火墙问题.看到下面的链接,那里有人遇到类似的问题-

This is mostly due to your hosting providers firewall issues. See on below link where someone had similar issue -

https://github.com/PHPMailer/PHPMailer/issues/295

联系您的托管服务提供商,他们将能够为您提供帮助

Contact your hosting provider, they will be able to help you

这篇关于SMTP错误:无法连接到服务器:连接被拒绝(111)错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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