SMTP ERROR: Failed to connect to server: (0)

I'm using AWS Elastic Beanstalk and can't send emails with PHPMailer. On my local server it works right with exactly the same configuration. AWS Elastic Beanstalk uses Red Hat 4.8.3-9... I have tried all PHPMailer troubleshooting techniques and they are all working normally. The only one that leaves me doubts is the "SELinux blocking" that I do not know if it will be a problem, but anyway the error is not the same.

I I tried using the getsebool httpd_can_sendmail command and the answer was this getsebool: SELinux is disabled.

The PHPMailer error:

SMTP ERROR: Failed to connect to server: (0)

Is this the problem? Does anyone know how to solve?

Cross Post: https://stackoverflow.com/q/42983283/1817673
Issue: https://github.com/PHPMailer/PHPMailer/issues/1013

Author: Comunidade, 2017-03-23

1 answers

"SMTP ERROR: Failed to connect to server: (0)" means there was no connection to the SMTP server, this means there is a connection lock, please review the following questions:

  • Make sure the host or ip address is valid;
  • Make sure the inserted port and authentication form are correct; (typically 587 without TLS/SSL or 465 if you support TLS/SSL)
  • make sure that your local or remote firewall is not blocking connections, so it is feasible to review the rules of both firewalls;
  • Make sure that the SMTP server allows an external connection, some providers block external connections;
 2
Author: RafaBR1, 2017-06-22 08:34:02