Configuring the local mail system
Without mail forwarding, emails intended for root are delivered to the address
(and generally emails for users
rootOotEPyQ-X@fitz=P9Xy7Y.munir5oa_F41i.czlogin will arrive at
login@fi.muni.cz ). For redirection, 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 case of installation questions (Debian/Ubuntu/...) choose
Internet with smarthost , enter the FQDN of your machine and as smarthost
[relay.fi.muni.cz] (including brackets). If not, you need to edit the file when configuring Postfix
# vi /etc/postfix/main.cf
and add a line
relayhost = [relay.fi.muni.cz]
and then run the command
# postfix reload
Ensure Postfix starts at system startup:
# systemctl enable postfix
Mail forwarding
Aliases are stored in a file
/etc/aliases (or
/etc/mail/aliases ):
# vi /etc/aliases
To redirect mail for users
root add a line
root: login@fi.muni.cz
Redirect your mail for your regular account anyway. It will apply the change and update the alias database.
# newaliases
For more information about aliases, see
man 5 aliases .
Hostname settings
Check that you have set the correct hostname including 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 in the Postfix package). It is secured by the package
mailutils or
s-nail . It is generally useful: some other services (e.g. [SMART daemon](installation.html#smart) rely on it.
Then verify that the 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 a command
sudo
To redirect emails of the form
*** SECURITY information for XY.fi.muni.cz *** to the non-implicit address add using the command
visudo to a new file
/etc/sudoers.d/mailto line
Defaults mailto = login@fi.muni.cz
But make sure that
/etc/sudoers contains a line
#includedir /etc/sudoers.d . Alternatively, edit directly
/etc/sudoers .
Redirecting emails from cron
To redirect emails from cron, you need to add the following line to the file from which the tasks are run before the task definitions:
MAILTO=login@fi.muni.cz
Troubleshooting
If you encounter problems during configuration, you may find the mail system logs, usually located in
/var/log/mail* ,
/var/log/postfix or
/var/log/exim*/ . You can find out the contents of the local mail queue with the command
mailq If you don't know what to do, we will advise you on
unixXq3_kNEju@fie1CWlG48o.muniRluyAPSvy.cz .
