Skip to main content

Using sendmail Rather Than mail

mail (from mailutils) is a common sysadmin tool for sending system mail, however, it brings in uneeded/undesired packages (e.g. mysql/mariadb tools). sendmail is much lighter and can usually get the job done.

Common mail Scenario

The following cron entry runs deborphan every monday at 14:33, emailing the results to the drad user.

33 14 * * Mon   deborphan --guess-all | mail -s "Weekly deborphan Report" drad

sendmail does not have a -s (subject parameter). You need to preface your message with "Subject: {your subject}" followed by a new line and then the body such as follows:

33 14 * * Mon   ( echo "Subject: Weekly deborphan Report"; echo; deborphan --guess-all ) | /usr/sbin/sendmail drad

The sendmail route is a little more verbose but gets the job done and now you do not need mailutils!