Configuring the local mail system
Without mail redirection, mail destined for the root is delivered to
(and in general mail for
rootT3LfTiN_w@finTzxhJOc6.muniZgFENcbha.czlogin users arrives at
login@fi.muni.cz). To redirect, you need to create an alias and properly configure a mail system that supports aliases (e.g. Postfix, Exim).
Mail system configuration (Postfix)
Install the package
postfix. In the case of installation queries (Debian/Ubuntu/...), select
Internet with smarthost, enter the FQDN of your machine as smarthost
[relay.fi.muni.cz] (including brackets) and you can leave the other entries default. Alternatively, you can then edit the Postfix configuration manually:
# vi /etc/postfix/main.cf
and add the line
relayhost = [relay.fi.muni.cz]
and then run the command
# postfix reload
Secure Postfix startup on system boot:
# systemctl enable postfix
Redirect Mail
The aliases are stored in the file
/etc/aliases (or
/etc/mail/aliases):
# vi /etc/aliases
To redirect mail for the user
root, add the line
root: login@fi.muni.cz
Redirect mail for your regular account in the same way. Apply the change and update the alias database
# newaliases
For more information about aliases, see
man 5 aliases.
Setting the hostname
Make sure you have the correct hostname set up, including the domain:
$ hostname
yourfimachine.fi.muni.cz
Typically, you can set the hostname with the command
# hostnamectl set-hostname yourfimachine.fi.muni.cz
Functionality test
Install the command
mail (not included with Postfix). It is provided by the
mailutils or
s-nail package. It is generally useful: some other services (e.g. [SMART daemon](installation.html#smart) rely on it.
Then verify that the test mail arrives in your faculty mailbox (for both root and your local login), e.g.:
$ echo A very short body | mail root -s Subject
$
Redirecting mail generated by the command
sudo
To redirect mail of the form
*** SECURITY information for XY.fi.muni.cz ***to a non-implicit address, add the line
visudo to the new file
/etc/sudoers.d/mailto
Defaults mailto = login@fi.muni.cz
However, verify that
/etc/sudoers contains the line
#includedir /etc/sudoers.d. Alternatively, edit
/etc/sudoers directly.
Redirecting mail from cron
To redirect mail from cron, you need to add a line to the file from which the tasks are run before the task definitions
MAILTO=login@fi.muni.cz
Troubleshooting
If you run into problems during configuration, the mail system logs, usually located at
/var/log/mail*,
/var/log/postfix or
/var/log/exim*/, can be useful. To find out the contents of the local mail queue, use the command
mailq. If you don't know what to do,
will help you.