Connection refused by [127.0.0.1]

email-serversendmailsmtp

I am not very good with email servers. Here is what I need:

I have a mailbox at fastmail.com with my custom domain (let's call it example.com). Now I want to set up my web server to relay emails through fastmail.com (I have their mx records in hand) and the no reply email address to be bot@example.com. I want to use sendmail to achieve this.

When I tried to send an email using sendmail, here is the log I got:

to=_myemailaddress_, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30088, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]

(myemailaddress being my own email address).

The relay server here is 127.0.0.1, which doesn't seem right. So, I digged and found the two files /var/mail/submit.cf and /var/mail/sendmail.cf. Then I searched for the line with the text "127.0.0.1":

// submit.cf
FEATURE(`msp', `[127.0.0.1]', `25')dnl

// sendmail.cf
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, M=Ea, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl

Should I change the addresses to fastmail MX records (in1-smtp.messagingengine.com, in2-smtp.messagingengine.com)?

Or should I do something else?

Best Answer

Sendmail requires root privileges for some actions. Modern installations avoid being set root is by passing messages to sendmail daemon running with root privileges at 127.0.0.1:25.

Your local sendmail daemon does not seem to be up and running.

  1. Check sendmail log files for any startup problems (log file names are OS/Distribution depended (e.g. /var/log/mail.log on Linux/Debian)

  2. Start/restart sendmail daemon (procedure OS/Distribution dependent)