How do I change a sendmail alias?

Actually, if you know what the title question means, you’re halfway there already. šŸ˜‰

Today a friend called and had a problem with a Debian system. The Linux sysadmin had left the company and the servers were still forwarding all the host mail to the now-former sysadmin’s personal email. My friend figured out that the /etc/mail/aliases was where the change was to be made, but after a restart of sendmail and the host itself, no change was effected.

This is where he called me. I love calls from this guy because its perfect fodder for this blog. Actually, since I’ve been asked this question a few times in the past, I figure there’re probably more of you out there that wonder the same thing. Anyway, back to the story; my friend had missed the crucial “step 2” of the process. Let me detail the whole process for those of you that are new to it…

Sendmail has the ability to accept and automatically forward mail to users outside of the system (as you would probably expect). The method is called using an “alias”, and the config file for such is likely to be /etc/mail/aliases (you may find a soft link at /etc/aliases).Ā  For postfix, the file you want is /etc/aliases.

To change/add/remove these aliases, perform these two steps:

  1. Open /etc/mail/aliases (again, for Postfix, /etc/aliases) in a text editor of your choice. Modify or add a line in such a way that it follows the form “<localuser>: <remoteuser>”. For example, “root: jpavlov@yourLinuxGuy.com” (without quotes, of course, and the space is optional).
  2. Once you are satisfied with the change and have saved the file, run the command: “newaliases“. This command is really just a special call to the sendmail binary, but it causes the /etc/mail/aliases *file* to be re-read and compiled into the /etc/mail/aliases.db *database* (on Postfix, the db is likely at /etc/aliases.db). This is what actuates the change for sendmail, allowing the new modified aliases to be used.

I hope that helps somebody. I know alot of you out there are using Postfix since it is now the dominant MTA on Linux in general, but there are still alot of distros that use Good ol’ Sendmail. And hey, Solaris still uses it, too, right?

šŸ˜‰

1 Comment

  1. Pingback: Your Linux Guy .com » Blog Archive » Handy little “rug lu” commands

Leave a Comment

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