You are here: Home Cheat Sheets Sendmail Hacks

Sendmail Hacks

Things i need to do with sendmail at work that i keep forgetting.

Pipe a single user to a file

Piping single non local addresses to a file is for mainly for debugging.

  • Add this to /etc/mail/sendmail.mc
MODIFY_MAILER_FLAGS(`RELAY', `+A')dnl

Preferably before the

MAILER(`smtp')

entry.

  • Run make
cd /etc/mail
make
  • Restart sendmail
/etc/init.d/sendmail restart
  • Run newaliases after adding this to /etc/mail/aliases
testuser@somedomain.com: /path/to/testuser/inbox

This file needs to exist and be accessible by the sendmail process. It will keep appending to this file mbox style


Pipe everything to a file

  • Create /etc/mail/mailertable
.     local:testuser
  • Run newaliases after adding this to /etc/mail/aliases
testuser: /path/to/testuser/inbox

This file needs to exist and be accessible by the sendmail process. It will keep appending to this file mbox style

  • Add this to /etc/mail/sendmail.mc
FEATURE(`mailertable',`hash -o/etc/mail/mailertable.db')dnl

The location is optional and only needed if mailertable.db is somewhere else

  • Run make
cd /etc/mail
make
  • Restart sendmail
/etc/init.d/sendmail restart

This refers to Linux and varies from platform to platform.


Send everything to a given account

This is largely like the above. Here are the differences

  • Create /etc/mail/mailertable
.     local:root
domain.com      smtp:[mx.domain.com]

This obviously need not be root, but i run this on an internal VM and don't care. It does need to match the account in aliases though. It is also necessary to add the domain.com record so that the forward to user@domain.com doesn't get resent to root. domain.com needs to match the domain of the user to forward to. The [mx.domain.com] entry should the the address of the actual SMTP host that handles emails for domain.com.

  • Add this to /etc/mail/aliases
root: user@domain.com

The remainder is as piping to a file.

Document Actions

Copyright © 2007-2015 Mario Theodoridis. All rights reserved. Content licensed under AFL.   Impressum   Datenschutz
Content from the underlying Plone CMS is © 2000-2009 by the Plone Foundation