Title: Configure relays
Course: CIS 208: Linux/UNIX III: Intermediate System Administration, Networking, and Security ~ For IGNITE Review > Section: Learning Modules

Configure Relays

It is possible to set up a separate server which accepts email connections from the Internet and then forwards the email to an internal server which hosts the users' mailboxes.  In this case, incoming email would be relayed.  After configuring postfix as described previously, several changes must be made.

- First, set the relay_host to be the internal mail server in /etc/postfix/main.cf.
- Next, copy all of the values for mydestination and include them in the relay_domains configuration.
- Finally remove all domains from mydestination except for localhost.
- Restart or reload postfix. No updates are needed on the internal mail server.

It is also possible to use a relay for outbound email.  This is known as a "smarthost" in sendmail.  Two methods are available, depending on whether or not authentication is required on the relay server.

- If authentication is not required to use the relay, simply add a relayhost option with the hostname or IP address of the relay in /etc/postfix/main.cf.  For example:

relayhost = smtp.myisp.com

- Restart or reload postfix.
- If authentication is required, two new files will need to be created in addition to the updates to main.cf.

This example shows how to set up authentication for an AT&T Uverse account.  The following lines are added to the /etc/postfix/main.cf file.

#Authenticated user settings for Uverse
relayhost = smtpauth.sbcglobal.net:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_creds
smtp_sasl_security_options =
sender_canonical_maps = regexp:/etc/postfix/sender_canonical

- The relay server need to be registered in /etc/postfix/sender_canonical.

/.*/ UverseId@att.net

- The credentials need to be stored in a file accessible only by root.  Create /etc/postfix/relay_creds with the user's email address and password.

smtpauth.sbcglobal.net:587 UverseId@att.net:PassWord

- The following commands will implement the new settings.

postmap /etc/postfix/relay_creds
postmap /etc/postfix/sender_canonical; service postmap restart
service postfix reload