sendmail

sendmail

configuration > server > email > sendmail

This is the standard MTA under FreeBSD and its package name is mini_sendmail. New setups and jails come with sendmail pre installed. It might not be interesting to use sendmail as a public mail transport agent, but if you want to avoid to configure another client every time these configurations might come handy. The main configuration path is /etc/mail/ The easiest way to configure sendmail under FreeBSD is by using the Makefile, which can be found under /etc/mail/. After having created a new jail it can be used by changing to that folder and executing make (without arguments). This first step will create files called $HOSTNAME.mc and $HOSTNAME.submit.mc out of the freebsd.mc and freebsd.submit.mc, where it is discouraged to edit the latter, because they may get replaced with the next update. So it is advisable to edit the $HOSTNAME*-files instead. To make sendmail redirect mails to another jail one needs this configuration:

/etc/mail/$HOSTNAME.submit.mc

FEATURE(masquerade_envelope)
MASQUERADE_AS(`jail.mail')
FEATURE(`msp', `jail.mail')

where jail.mail stands for the mail receiving jail and can be assigned to an IP-address using the /etc/hosts-file. This makes the sender address being root@jail.mail, which may be misleading, but simplifies things a lot. To make mails from different jails distinguishable by the senders address, I am using chpass in order to change the senders default Charlie Root full user name to something more meaningful. Finally the setup can be applied with make all install restart It should now be possible to send a test mail from within that jail like so: echo content of testmail \| mail -vvv -s mysubject root

caveats

It has proven to be good practice to keep an eye on /var/log/maillog while testing. There might appear an error hash map "generics": unsafe map file /etc/mail/genericstable.db: Permission denied and if that happens it probably means, that sendmail cannot read it. The reason is, that the Makefile sets the files permissions to 640=rwxr----, but by default sendmail seems to get executed as user smmsp. A chgrp -R smmsp /etc/mail/ is my current fix for that.

Make use of another smtp server for delivery

I recently found out, that sendmail.mc is based on the traditional m4 language, which also gets used for gEDA footprints, which I have already been in contact with. Shame on me.

/etc/mail/client-info

AuthInfo:smtp.1und1.de "U:root" "I:[USERNAME]" "P:[PASSWORD]"
cd /etc/mail/
makemap hash client-info < client-info

/etc/mail/sendmail.mc

FEATURE(`authinfo',`hash /etc/mail/client-info')dnl
dnl MASQUERADE_AS('entwicklerseite.de')dnl
MASQUERADE_AS(entwicklerseite.de)dnl
FEATURE(`masquerade_envelope')dnl
LOCAL_DOMAIN(`entwicklerseite.de')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl
define(`SMART_HOST',`smtp.1und1.de')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')
cd /etc/mail/
make
echo 'your-mail-addy@host.de' > /root/.forward
systemctl restart sendmail

further reading and sources https://confighell.com/Sendmail

Command cheat sheet

rm -f /var/spool/mqueue/* ;# deletes all mails from the mail queue (undelivered!)
pw usermod -n root -c 'www jail root' ;# configure roots comment so that it appears as true name in mails
top