6

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" [email protected]`

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.

10
  • So you are trying to send a mail to the local server? In that case just use me@localhost.
    – Thomas
    Jan 13, 2017 at 17:26
  • Thanks, but nope, I'm trying to send mail to the outside world. Apparently the mail server was working with the php web app at one point, but then mysteriously stopped working one day due to connection refused on port 25.
    – Rick Jolly
    Jan 13, 2017 at 17:31
  • Do you know which mail server is running on example.com? Maybe postfix?
    – Thomas
    Jan 13, 2017 at 17:37
  • can you open a socket outbound on port 25? nc vegas.jacobdevans.com 25 -v Jan 13, 2017 at 17:37
  • -bash: nc: command not found
    – Rick Jolly
    Jan 13, 2017 at 17:38

1 Answer 1

6

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/

2
  • Thanks @DBLaci. I'll look into it and get back to you. Just out for a few hours.
    – Rick Jolly
    Jan 13, 2017 at 20:07
  • 1
    Thanks so much. The ISP was blocking port 25. I could send using my gmail creds on port 587.
    – Rick Jolly
    Jan 16, 2017 at 0:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .