My VPS image (Debian 6) comes pre-installed with sendmail as the MTA. I will use this server as a web server, and maybe other usages but not as a mail server. I want to remove as many unneeded services as possible to save resources. Can the MTA be safely removed? What are the consequences?
One consequence of removing the MTA is that mail generated by the system itself (usually sent to root), for example by Cron, Logwatch, rkhunter and others cannot be be delivered.
So yes, an MTA is an integral part of any Unix-like system and I doubt Debian will let you uninstall the MTA without complaining and suggesting an alternative. But it's not a big deal. By default in Debian even
sendmail will only listen on 127.0.0.1 and relay mail only locally, so there is no real security risk here.
The MTA is used to handle all kinds of messaging, not just email to user mailboxes. On my CentOS system, it is using a whopping 4 MB of RAM. That's less than one PHP thread. Don't jeopardize the stability and operation of your server for a pittance of extra capacity. Buy more capacity instead.
Instead of removing sendmail (or any other MTA) for reasons explained in other answers, you can configure it to send all system generated email to a mail account of your choice, so as to review it at a later time.
Since this is a Debian system, backup your
/etc/mail/sendmail.mc and then replace it with the contents below:
VERSIONID(`2006/08/23/00')dnl OSTYPE(`debian')dnl DOMAIN(`debian-mta')dnl dnl # define(`SMART_HOST', `[outgoing.example.com]')dnl define(`confCW_FILE', `-o /etc/mail/local-host-names')dnl FEATURE(`use_cw_file')dnl FEATURE(`no_default_msa')dnl DAEMON_OPTIONS(`Name=MTA-v4, Addr=127.0.0.1, Port=smtp')dnl DAEMON_OPTIONS(`Name=MSP-v4, Addr=127.0.0.1, Port=submission')dnl MAILER(`local')dnl MAILER(`smtp')dnl LOCAL_RULE_0 # LHS is separated from RHS with tabs, not whitespaces R$- <@ $=w . > john.doe < @ example.com. >
- You may not need the SMART_HOST line. That is why it is already commented out.
- In the last line the left hand side is separated from the right hand side with tabs, not spaces. So do not copy-paste, type by hand.
After you are done, run
sendmailconfig and check whether this solution works for you.