Configuring sendmail as an MSA

[Disclaimer: sendmail is very complicated, and I lack some knowledge. The following solution might be even bad, although it works (tm). Please post comments if you know better ways, and I'll update the post]

I was looking for a quick n' simple SMTP solution for sending mails only. Requirements:

  • A service that'll simply accept mails submitted locally and maintain a queue of mails-for-sending.
  • It'll then send the mails by SMTP directly to the target servers (i.e. gmail.com).
  • It should retry for a few days, if failed sending due to a local (dead connection) or remote problem.
  • A bizarre one: it should be listening on a port other than 25, because another daemon uses it already. I know it's nonstandard and doesn't make sense, but should be possible..

Apparently what I was looking for is an Mail Submission Agent (MSA), which also takes care of delivering the mail. Also there's a standard port for mail submission: 587 (submission).

I'm using CentOS 5, which comes by default with sendmail, so using the native service is an advantage.

After some digging in sendmail docs, I've found that all my requirements could be met by changing 3 lines, based on the default configuration (yum install sendmail-cf to get it):

/etc/mail/sendmail.mc:

  • Added an MSA listener on port 'submission' (587):

    DAEMON_OPTIONS(`Port=submission,Addr=127.0.0.1, Name=MSA')

  • Removed the following line to prevent MTA on port 25:

    DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')

/etc/mail/submit.mc

  • Added the following line to enable MSA mode:

FEATURE(`msp'," "FEATURE(`msp', `[127.0.0.1]', `MSA')

The final part: "Compiling" sendmail's configuration

m4 /etc/mail/submit.mc > /etc/mail/submit.cf

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

service sendmail restart

Viola.

One thought on “Configuring sendmail as an MSA

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>