user126960
user126960

Reputation: 11

Error sending email to [email protected] SMTP connect() failed. in PHPList

I have configured phplist in my localhost and its working fine and i am able to send and receive mails and users can also register there successfully.

But when i move the same application on live server it is not sending any mail and in events log of phplist i am get the error mentioned in title.

i am not sure this is a port error or something else

any suggestions??

Here is my code under config.php

define("PHPMAILER",1);
define("PHPMAILERHOST",'smtp.mydomain.com');
$phpmailer_smtpuser = 'smt_user';
$phpmailer_smtppassword = 'smtp_password';
define('PHPMAILERPORT',25);

Upvotes: 0

Views: 4517

Answers (2)

GAURAV PAWAR
GAURAV PAWAR

Reputation: 43

In my case I Check the maillog at - /var/log/maillog I got the following error :-

...
 postfix/sendmail[2339]: fatal: parameter inet_interfaces: no local interface found for ::1
...

Check status of postfix MTA service using command -

systemctl status postfix.service

If service is not running open the postfix configuration file -

nano /etc/postfix/main.cf

Fix from postfix config file will require a minor change by replacing localhost with 127.0.0.1 from directive inet_interfaces.

...
inet_interfaces = 127.0.0.1
...

Restart postfix service -

service postfix restart

Check status -

systemctl status postfix.service

Now you will be able to send emails.

Upvotes: 0

Gui
Gui

Reputation: 9813

This question has almost 2 years but it's important to be answered as according to statics many people still land here after a few searches.

Error description

PHPList will show you this error when some network issue happens with your configuration. I've faced this error a few times with different reasons:

DNS: some hosting providers will block or redirect the DNS request to mail SMTP servers of famous providers like Google. Confirm it using dig command.

Firewall: this is the most common reason. Hosting providers also block the ports 465, 587 and/or 25. When at Unix, you may use a tool life UFW to manage IPTables rules and forget to allow outgoing connections from your hosting. You may want to stop UFW to confirm it's it's "fault".

Mail Server Security Layer: i've followed a few articles about mail server setup and they recommend you third party tools to improve security. The same way google will mostly block your first attempt from a remote server to connect to your account via SMTP, so your mail server may block if you're using some addon. Re-check all the steps done in mail server configuration and assert nothing is blocking the connection.

The error described by PHPList is good enough: the PHPMailer library isn't able to send the email to the remote host. Check the logs at /var/logs/mail.{err,info,log} not only from your remote host but also the host where the PHPList is installed, in case it's trying to send from itself.

If you're able to connect to your email account with a email client, and using the same settings you can't then it's a network issue.

At PHPList configuration file you don't need more than this:

define("PHPMAILERHOST",'smtp.example.com');
$phpmailer_smtpuser = '[email protected]';
$phpmailer_smtppassword = 'yourpw';
define('PHPMAILERPORT','587');
define("PHPMAILER_SECURE",'tls'); // or ssl 

There're a few outdated recommendations about adding more variables and defining more constants at configuration but you don't need it.

Upvotes: 1

Related Questions