http://www.brandonhutchinson.com/Creating_a_new_sendmail_mailer.html

Creating a new sendmail mailer

Example one

Situation: a remote mail server began TEMPFAILing connections after receiving 20 envelopes from our relays with the following message:

451 Error in processing Number of messages exceeds maximum per connection

I would like to send a maximum of 20 envelopes to example.com, but would like to use the default value (if m= is not present in the mailer definition, send an unlimited number of envelopes) for all other domains.

I could use the define(`SMTP_MAILER_MAXMSGS', `value') macro configuration file value to limit the number of envelopes delivered per connection, but that value would affect all SMTP connections rather than just those to example.com.

In order to achieve my goal, I must define a new mailer.

1. Add the following line to sendmail.mc:
MAILER_DEFINITIONS

2. Copy and paste the esmtp mailer definition from an existing sendmail.cf file into sendmail.mc immediately below MAILER_DEFINITIONS.

Mesmtp,         P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r
\n, L=990,
                T=DNS/RFC822/SMTP,
                A=TCP $h

3. Modify the name of the mailer in sendmail.mc and add an m= value.

Mesmtp_mailer_maxmsgs_20,         P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r
\n, L=990,
                m=20, T=DNS/RFC822/SMTP,
                A=TCP $h

4. Build and install the new sendmail.cf file.

# ./Build install-cf
# kill -HUP `head -1 /var/run/sendmail.pid`

5. Add a mailertable entry to use the new mailer for example.com recipients and build the mailertable database.

/etc/mail/mailertable entry:
example.com    esmtp_mailer_maxmsgs_20:example.com

# makemap hash /etc/mail/mailertable < /etc/mail/mailertable


6. Test the configuration with sendmail -bv.

# sendmail -bv user@example.com
user@example.com... deliverable: mailer esmtp_mailer_maxmsgs_20, host example.com, user user@example.com

Example two

Situation: a remote mail server began slowing down our SMTP connection noticeably after we specified 15 recipients in an envelope; after we specified more than 20 recipients in an envelope, this remote mail server TEMPFAILed with the following message:

452 Too many recipients

I would like to send a maximum of 15 recipients per envelope to example.com, but would like to use the default value (if r= is not present in the mailer definition, send up to 100 recipients per envelope) for all other domains.

1. Add the following line to sendmail.mc:
MAILER_DEFINITIONS

2. Copy and paste the esmtp mailer definition from an existing sendmail.cf file into sendmail.mc immediately below MAILER_DEFINITIONS.

Mesmtp,         P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r
\n, L=990,
                T=DNS/RFC822/SMTP,
                A=TCP $h

3. Modify the name of the mailer in sendmail.mc and add an r= value.

Mesmtp_mailer_maxrcpts_15,         P=[IPC], F=mDFMuXa, S=EnvFromSMTP/HdrFromSMTP, R=EnvToSMTP, E=\r
\n, L=990,
                r=15, T=DNS/RFC822/SMTP,
                A=TCP $h

4. Build and install the new sendmail.cf file.

# ./Build install-cf
# kill -HUP `head -1 /var/run/sendmail.pid`

5. Add a mailertable entry to use the new mailer for example.com recipients and build the mailertable database.

/etc/mail/mailertable entry:
example.com    esmtp_mailer_maxrcpts_15:example.com

# makemap hash /etc/mail/mailertable < /etc/mail/mailertable


6. Test the configuration with sendmail -bv.

# sendmail -bv user@example.com
user@example.com... deliverable: mailer esmtp_mailer_maxrcpts_15, host example.com, user user@example.com


Back to brandonhutchinson.com.
Last modified: 2008/06/02