Ошибка подключения к серверу smtp 111

Sorry if this is a road heavily traveled. I’ve seen the other posts about this but nothing in them has either solved the problem I’m having or ignited a lightbulb that helped me solve it myself.

Here’s my code:

require 'PHPMailerAutoload.php';
$config = parse_ini_file('/path/to/file/config.ini', true);
$mail = new PHPMailer;
$mail->SMTPDebug = 3;
$mail->Debugoutput = 'html';
$mail->isSMTP();
$mail->Host = $config['host']; //smtp.office365.com
$mail->SMTPAuth = true;
$mail->Username = $config['username']; //an.existing.account@appinc.co
$mail->Password = $config['password']; //confirmed this is being passed correctly
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->From = $config['username'];
$mail->FromName = 'Website Forms';
$mail->addAddress('sales@appinc.co', 'Some Name');
$mail->addReplyTo('sender.email@somedomain.com', 'SenderFirst SenderLast');
$mail->addBCC('my.email.address@appinc.co');
$mail->isHTML(true);
$mail->Subject = 'Contact Form Submission';
$mail->Body = 'Some html here';
$mail->AltBody = 'Some alt content here';
if(!$mail->send()) {
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    //perform success actions
    exit();
}

I’ve confirmed that the domain, username and password are all correct and being passed in correctly. Important to note that this worked on our local dev server prior to launch. Once the site was moved to our hosting account (Hostgator) is when it stopped working. I’ve confirmed with HG that port 587 is open on our server.

Here is the error message I’m seeing:

Connection: opening to smtp.office365.com:587, t=10, opt=array ()
SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed.
Message could not be sent.Mailer Error: SMTP connect() failed.

Any help that can be provided is very much appreciated, even if it’s just a link to an article that explains why it won’t work now that it’s in our production environment.

Есть 3 сервера.
1 mailwizz -web программа для отправки писем
2 mailwizz -web программа для отправки писем
3 почтовый сервер

оба mailwiz — по конфигурации вроде как идентичны
на почтовом сервере 587 порт открыт, ограничений на mailwizz сервера нет, все в порядке
mailwizz,ы подключаются к почтовому серверу через smtp
почтовым сервером управляет PMTA, сертификаты настроены — другой майлвиз шлет

проблема:
1 mailwizz — прекрасно коннектится по 587 к почтовому серверу и шлет письма
2 mailwizz — не как не хочет, пишет ошибку

SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Connection: opening to m-spf.ru:587, timeout=30, options=array ( 'ssl' => array ( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ),)
Connection failed. Error #2: stream_socket_client(): unable to connect to postal.ru:587 (Connection refused) [/var/www/mailwizz/data/www/mailwizz.ru/apps/common/vendors/Composer/vendor/phpmailer/phpmailer/src/SMTP.php line 387]
SMTP ERROR: Failed to connect to server: Connection refused (111)

на проблемном сервере mailwizz
— панель isp manager
— PHP Version 7.3.19
— SSL Version OpenSSL/1.0.2u
openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.1.0l 10 Sep 2019
OpenSSL Header Version OpenSSL 1.1.0l 10 Sep 2019
Openssl default config /usr/lib/ssl/openssl.cnf
Native OpenSSL support enabled

все что про него знаю, вроде тоже самое что на другом mailwizz

Как можно мой майлвиз подружить с 587 портом моего почтового сервера.

What’s Causing This Error

The SMTP 111 error occurs when an issue is present while connecting with the remote SMTP server. For example, you would run into this error due to invalid sender domains or firewall issues.

Additionally, with some mail servers (Amazon SES in particular), you may encounter the 111 error due to invalid login credentials or if the email sending port gets blocked by the recipient.

Solution — Here’s How To Resolve It

First, ensure that the email address to which you’re sending the email is spelled correctly (especially the domain name). For example, if you’re sending the email to a Gmail domain, ensure that the domain is «gmail.com.»

Then, ensure that you’ve provided the correct username and password for SMTP authentication.

Finally, ensure that the email sending port is available for use on your end, and ensure that the port gets accepted on the recipient’s end.

However, you can only troubleshoot the SMTP server for firewall issues if the error persists by connecting to the recipient SMTP server through your local computer. If you cannot connect to the server through your local computer, the issue may likely occur on the recipient’s end. Therefore you may have to contact the recipient for more information.

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!";
    }
    ?>

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 ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. /wiki/Troubleshooting
Mailer Error: SMTP connect() failed.

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!

Thanks…

asked Apr 19, 2018 at 10:08

4

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

answered Apr 23, 2018 at 13:31

mdeora's user avatar

mdeoramdeora

4,1622 gold badges19 silver badges29 bronze badges

I tried your code with my email and token, also not work, it shows :

2018-04-28 13:52:41     SMTP ERROR: Failed to connect to server:  (0)
2018-04-28 13:52:41     SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

then i changed below two lines:

$m->SMTPSecure = 'ssl';
$m->Port = 465;

to

$m->SMTPSecure = 'tls';
$m->Port = 587;

then, it works

    ...
2018-04-28 13:53:13     SERVER -> CLIENT: 354 Start mail input; end with <CRLF>.<CRLF>
2018-04-28 13:53:13     CLIENT -> SERVER: Date: Sat, 28 Apr 2018 21:53:04 +0800
2018-04-28 13:53:13     CLIENT -> SERVER: To: "feiffy" <example@example.com>
2018-04-28 13:53:13     CLIENT -> SERVER: From: feiffy <feifeifanye@hotmail.com>
2018-04-28 13:53:13     CLIENT -> SERVER: Reply-To: "feiffy" <example@example.com>
2018-04-28 13:53:13     CLIENT -> SERVER: Subject: Here is an email
2018-04-28 13:53:13     CLIENT -> SERVER: Message-ID: <hW4npgJlHQ2CjCqR42xK7j7BRpAzEFAz8mnwK4G6o@pc>
2018-04-28 13:53:13     CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.5 (https://github.com/PHPMailer/PHPMailer)
2018-04-28 13:53:13     CLIENT -> SERVER: MIME-Version: 1.0
2018-04-28 13:53:13     CLIENT -> SERVER: Content-Type: multipart/alternative;
2018-04-28 13:53:13     CLIENT -> SERVER:       boundary="b1_hW4npgJlHQ2CjCqR42xK7j7BRpAzEFAz8mnwK4G6o"
2018-04-28 13:53:13     CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2018-04-28 13:53:13     CLIENT -> SERVER:
2018-04-28 13:53:13     CLIENT -> SERVER: This is a multi-part message in MIME format.
2018-04-28 13:53:13     CLIENT -> SERVER: --b1_hW4npgJlHQ2CjCqR42xK7j7BRpAzEFAz8mnwK4G6o
2018-04-28 13:53:13     CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2018-04-28 13:53:13     CLIENT -> SERVER:
2018-04-28 13:53:13     CLIENT -> SERVER: This is the body of an email
2018-04-28 13:53:13     CLIENT -> SERVER:
2018-04-28 13:53:13     CLIENT -> SERVER: --b1_hW4npgJlHQ2CjCqR42xK7j7BRpAzEFAz8mnwK4G6o
2018-04-28 13:53:13     CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2018-04-28 13:53:13     CLIENT -> SERVER:
2018-04-28 13:53:13     CLIENT -> SERVER: This is the body of an email
2018-04-28 13:53:13     CLIENT -> SERVER:
2018-04-28 13:53:13     CLIENT -> SERVER:
2018-04-28 13:53:13     CLIENT -> SERVER: --b1_hW4npgJlHQ2CjCqR42xK7j7BRpAzEFAz8mnwK4G6o--
2018-04-28 13:53:13     CLIENT -> SERVER:
2018-04-28 13:53:13     CLIENT -> SERVER: .
2018-04-28 13:53:14     SERVER -> CLIENT: 250 2.0.0 OK <hW4npgJlHQ2CjCqR42xK7j7BRpAzEFAz8mnwK4G6o@pc> [Hostname=SG2PR06MB0776.apcprd06.prod.outlook.com]
2018-04-28 13:53:14     CLIENT -> SERVER: QUIT
2018-04-28 13:53:14     SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel

hope to help you.

answered Apr 28, 2018 at 14:07

feiffy's user avatar

I’ve been using mailgun and I love it. Mailgun.com Totally free for a case like this.

As a suggestion, can you see if there’s a sendmail daemon running on your box? Maybe that will be good enough for your use case?

answered Apr 25, 2018 at 21:35

Lucas's user avatar

LucasLucas

4693 silver badges7 bronze badges

1

Stuck with Amazon SES SMTP Connection refused (111) error? We can fix it for you.

Quite often, when connecting apps to Amazon SES Mail service, users get errors. This happens mainly due to incorrect port settings, invalid logins, etc.

At Bobcares, we frequently deal with AWS errors as part of our AWS Support Services.

Today, we’ll see how our Expert Engineers fixed the SMTP error and made the emails work.

More about Amazon SES SMTP connection

In simple words, Amazon Simple Email Service aka Amazon SES allows users to send emails from their own domain names. Here, users do not have to invest time and resources to manage their own mail servers.

Moreover, Amazon SES integrates well with popular applications like WordPress and other AWS products too. That is why many app owners route their emails to Amazon SES Mail service.

Amazon SES SMTP connection allows sending emails using an SMTP username and password. This information lies at the AWS Management Console >> SES tab, under SMTP Settings.

What causes Amazon SES SMTP Connection refused (111) error?

Now that we have a basic idea of the Amazon SES, let’s get into the details of the error.

The customer was already having a WordPress website. It had a form that sends mails to the users.

To improve the email deliverability, he added a WP SMTP plugin, so that they can route mail via Amazon SES service. However, it reported

SMTP ERROR: Failed to connect to server: Connection refused (111) SMTP connect() failed.

Then the test email function interface showed up as:

Amazon ses smtp connection refused 111

Such connection refused errors can occur due to many reasons including:

Wrong SMTP login details

Many times, users add wrong SMTP login details. The Amazon SES SMTP login details are different from the normal AWS logins. Thus, the mail application will refuse to connect to the Amazon SES.

Port restrictions

Similarly, yet another common reason for connection refusal can be port restrictions. For the emails to work, the port sending emails should not be blocked on the server.

How we fixed Amazon SES SMTP Connection refused (111) error

We’ll now check how our Support Engineers fixed the Amazon SES SMTP Connection refused (111) error for the customer.

As the first step, we verified the SMTP login details from the AWS SES interface. Then we confirmed that the customer was using the correct configuration in the WordPress mail settings. This included the SMTP host, port, encryption settings, etc.

Amazon SES SMTP settings

Next, we checked whether the connection to the mail server was working correctly from the WordPress server. However, the connection on port 465 was failing.

$ telnet email-smtp.xxx-2.amazonaws.com 465
Trying 35.xx.yy.92...
telnet: Unable to connect to remote host: Connection refused

And that resulted in the connection refused error.

It was not allowing connection out from our server due to a port/firewall problem. Therefore, we opened the outbound 465 connection on the server firewall. Thus, the port 465 connection started establishing successfully. Finally, mail started working fine too.

[Need help in debugging Amazon SES errors? We are available 24×7.]

Conclusion

To sum up, Amazon SES SMTP Connection refused (111) error happens due to email port restrictions, wrong login credentials, etc. Today, we saw how our Support Engineers resolved the error and made emails working on a WordPress website.

Get 24×7 monitoring for your AWS servers

There are proven ways to get even more out of your AWS Infrastructure! Let us help you.

Spend your time in growing business and we will take care of AWS Infrastructure for you.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

Понравилась статья? Поделить с друзьями:
  • Ошибка печати 1905 0x00000771 указанный принтер был удален
  • Ошибка планирования нобелевская премия
  • Ошибка победителя это
  • Ошибка печати 1722 0х000006ba сервер rpc недоступен
  • Ошибка пневмы туарег 01400