Using Linux mail - Connection Refused
You might want to send out a mail from your server, which is running a (mostly) properly configured sendmail service, but it fails:
123 | $ mail -v -s "Test" name@host.com <<< 'Message Body'
name@host.com... Connecting to [127.0.0.1] via relay...
name@host.com... Deferred: Connection refused by [127.0.0.1]
|
Solution:
1 | sudo vi /etc/mail/sendmail.cf
|
Then go down to the line that looks like this
1 | O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA
|
Add a new line, where Addr is your server's IP address (use
ifconfig
):
12 | O DaemonPortOptions=Port=smtp,Addr=xx.xx.xx.xx, Name=MTA
O DaemonPortOptions=Port=smtp,Addr=127.0.0.1, Name=MTA
|
Then, depending on your distro, you'll do this or something similar:
1 | sudo service sendmail restart
|
And you're off and running.
Ches Koblents
June 21, 2017