Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
documentation.suse.com / Configuring mail forwarding for the root user

Configuring mail forwarding for the root user

Publication Date: 27 Sep 2024
WHAT?

This article describes how to configure mail forwarding for the root user.

WHY?

Enable mail forwarding for the root user to get information about system events.

EFFORT

It should not take longer than five minutes to configure mail forwarding.

REQUIREMENTS
  • A network connection

  • A remote e-mail account that reliably receives messages

  • root or sudo privileges

1 Introduction

System daemons, cron jobs, systemd timers, and other applications can generate e-mails and send them to the root user of the system. These messages can contain security-relevant reports and incidents that might require a quick response by the system administrator.

By default, each user account owns a local mailbox and will be notified about new mail messages upon login. To get notified about the messages sent to root in a timely fashion, it is recommended to forward these mails to a dedicated remote e-mail account that is regularly checked.

2 Configuring root mail forwarding with YaST

The following procedure describes how to configure mail forwarding for the root user to a dedicated remote e-mail account.

Procedure 1: Configure root mail forwarding with YaST
  1. Install the yast2-mail package:

    > sudo zypper in yast2-mail
  2. Run the interactive YaST mail configuration:

    > sudo yast mail
  3. Choose Permanent as Connection type and proceed with Next.

  4. Enter the address of the Outgoing mail server. If necessary, configure Authentication. It is strongly recommended to Enforce TLS encryption to prevent potentially sensitive system data from being sent unencrypted over the network. Proceed with Next.

  5. Enter the e-mail address to Forward root's mail to and Finish the configuration.

    Important
    Important: Do not accept remote SMTP connections

    Do not enable Accept remote SMTP connections, otherwise the local machine will act as a mail relay.

  6. Send a message to test whether the mail forwarding works correctly:

    > mail root
    subject: test
    test
    .
  7. Check the remote e-mail account for new messages. Your test message should arrive within minutes.

3 What's next?

Depending on the number of managed machines and the number of persons who need to be informed about system events, different e-mail address models can be established:

  • Collect messages from different systems in an e-mail account that is only accessed by a single person.

  • Collect messages from different systems in a group e-mail account (aliases or mailing list) that can be accessed by all relevant persons.

  • Create separate e-mail accounts for each system.

It is crucial that administrators regularly check the related e-mail accounts. To facilitate this effort and identify important events, avoid sending unnecessary information. Configure applications to send only relevant information.

4 Troubleshooting

If the test message sent in Procedure 1, “Configure root mail forwarding with YaST” does not arrive, perform the following steps to analyze the problem.

Is the postfix daemon running?

Check if the postfix daemon is running with systemctl status postfix.service. If the service is down, the output includes additional information on the cause of the problem.

Has the test message been sent?

Use the mailq command to verify that the test message from Step 6 has been sent. Upon success, the queue should be empty.

Is the outgoing mail server resolved correctly?

Check that the system resolves the mail server of the remote e-mail account correctly. Run host -t mx example.com (where example.com is the domain of the e-mail account configured in step 5).

Can you reach the outgoing mail server?

Verify you can ping the mail server with ping -c 5 mail.example.com (where mail.example.com is the host name of the mail server returned by the host command in the previous step).

Does the test message still not arrive?

If mailq reports the message has been sent successfully, the problem must be on the receiving end. Check the configuration of the remote e-mail account and its spam folder.