Sendmail Hacks
Things i need to do with sendmail at work that i keep forgetting.
Pipe everything to a file
- Create /etc/mail/mailertable
. local:testuser
- Add 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.