Configuring the local email system
Without mail forwarding, emails intended for root are delivered to
(and, generally speaking, emails for the user
root1Mp0TwYiz@fikQnYsB5WV.muni7fdJ-fiP2.czlogin will arrive at
login@fi.muni.cz). To set up forwarding,
you need to create an alias and correctly configure an email system that supports
aliases (e.g. Postfix, Exim).
Configuring the email system (Postfix)
Install the package
postfix. If you have any installation queries
(Debian/Ubuntu/...) select
‘Internet with smarthost’, enter the FQDN of your
machine as the smarthost
[relay.fi.muni.cz] (including the brackets) and leave the other
items at their default values. Alternatively, you can then edit the
Postfix configuration manually:
# vim /etc/postfix/main.cf
and add the line
relayhost = [relay.fi.muni.cz]
and then run the command
# postfix reload
Ensure Postfix starts at system boot:
# systemctl enable postfix
Mail forwarding
Aliases are stored in the file
/etc/aliases (or
/etc/mail/aliases):
# vim /etc/aliases
To redirect mail for the user
root, add the line
root: login@fi.muni.cz
Similarly, redirect mail for your regular account. The change will take effect and the alias database will be updated
# newaliases
For more information on aliases, see
man 5 aliases.
Hostname settings
Check that you have set the correct hostname, including the domain:
$ hostname
yourfimachine.fi.muni.cz
Typically, you can set the hostname using the command
# hostnamectl set-hostname yourfimachine.fi.muni.cz
Functionality test
Install the `
mail ` command (not included in the Postfix package). You can obtain
it from
mailutils or
s-nail. It is generally useful: some other
services (e.g. the [SMART daemon](installation.html#smart)) rely on it.
Then check that a test email arrives in your faculty mailbox (for both root and your local login), e.g.:
$ echo A very short body | mail root -s Subject
$
Redirecting emails generated by the command
sudo
To redirect emails of the form
*** SECURITY information for XY.fi.muni.cz ***
to a non-default address, use the command
visudo to add the following line to the new file
/etc/sudoers.d/mailto
Defaults mailto = login@fi.muni.cz
However, please check that
/etc/sudoers contains the line
#includedir /etc/sudoers.d.
Alternatively, edit
/etc/sudoers directly.
Redirecting emails from cron
To forward emails from cron, you need to add the following line to the file from which the tasks are run, just before the task definitions:
MAILTO=login@fi.muni.cz
Troubleshooting
If you encounter problems during configuration, the mail system logs may be useful;
these are usually located at
/var/log/mail*,
/var/log/postfix or
/var/log/exim*/. You can view the contents of the local mail queue using the command
mailq.
If you are unsure what to do, we can advise you at
.