I'm trying to send email through a Postfix server. From the command line, if I enter:
echo "This is the body of the email" | mail -s "subject line" me@example.com`
Then the error I see in log/mail.info is:
postfix/smtp[23093]: connect to mail.mydomain.com[my.ip.add.here]: Connection refused (port 25)
If I enter netstat -an |more, I see:
...
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
...
No 0.0.0.0:25
if that makes a difference?
Edit
If I run netstat -plntu
, then I see 3587/master
as the pid/program name for 127.0.0.1:25. I see no postfix listed for pid/program name. Could it be that the mail server isn't running. I was told that it was.
...
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3587/master
...
Edit
Confirmed Postfix is running by typing postfix start
Edit
Tried this on the server if it helps:
telnet mail.mydomain.com 25
Trying 202.192.77.135...
telnet: connect to address 202.192.77.135: Connection refused
I know this problem has been solved many times, but I'm a simple web developer and I might need a little more guidance. Thank you.
Best Answer
The mail log shows that you CAN connect to your postfix server (on localhost). The postfix cannot connect to the external smtp server (mail.mydomain.com), and you can't connect with telnet either.
Perhaps you have a firewall (at your ISP) that blocks the outgoing smtp. This is common to block spam. For workaround you can use other mail server (gmail?) for relaying your e-mails, and connect to it on secure smtp (port 465 / 587) and authentication.
This is a great howto for this: https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/