Error sending email SMTP connect() failed. Using phpList

I’ve installed MiaB on a linode server and I’ve setup PhPList like this:

define(‘PHPMAILERHOST’, ‘box.mybox.com:587’);
$phpmailer_smtpuser = ‘user@mybox.com’;
$phpmailer_smtppassword = ‘mypassword’;
define(“PHPMAILER_SECURE”,‘tls’);

and I get this error when I try to send an email: Error sending email to myemail@gmail.com SMTP connect() failed.

Using the same settings on thunderbird works fine, does anyone know what the problem is?

Just a guess, but can you use STARTTLS rather than tls

Just tried it and it doesn’t work.

SMTP ERROR: Failed to connect to server: Network is unreachable (101)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

So what are the error logs showing?

Error sending email to myemal@gmail.com SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Is phpmailer on another Ubuntu instance? If so the error log is going to be located at /var/log/mail.err or the specific event may be logged in /var/log/mail.log

The important log will be the one on the MiaB instance itself.

The error message really doesn’t say much.

Or even better what are the results when you use SMTPDebug as outlined in the linked troubleshooting guide?

MiaB is on a linode server, PHPList is on another server.

phplist SMTPDebug is set and it shows this:

Connection: opening to box.mybox.com:587, timeout=5, options=array ()
Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to box.mybox.com:587 (Network is unreachable)
SMTP ERROR: Failed to connect to server: Network is unreachable (101)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

MiaB /var/log/mail.log shows nothing when I try to send a mail from phplist.

The log entry seems to suggest that the PHPList server cannot access the MiaB server on port 587, and the MiaB server showing nothing seems to support this.

From the PHPList server, do you get something similar to below:

$ curl box.mybox.com:587
220 box.mybox.com ESMTP Hi, I'm a Mail-in-a-Box (Ubuntu/Postfix; see https://mailinabox.email/)
221 2.7.0 Error: I can break rules, too. Goodbye.

Has the provider of the other server blocked mail ports by chance? It looks to me as though you are unable to communicate out on port 587 from the error message that you posted. Maybe you can reach out to support and ask them if mail ports are blocked and to unblock if so.

Port was blocked, it is unblocked now and everything works. Thank you guys for you help @alento @openletter

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.