Force sendmail to route mail to specific hosts or mailserver

ht‮w//:spt‬ww.lautturi.com
Force sendmail to route mail to specific hosts or mailserver

Sendmail is a popular mail transfer agent (MTA) used on Unix-like systems to send and receive email. To force sendmail to route mail to specific hosts or a specific mail server, you can use the mailertable feature of sendmail.

The mailertable feature allows you to specify a mapping between domain names and mail servers or hosts. When sendmail receives an email for a domain that is specified in the mailertable, it will route the email to the specified server or host instead of using the default routing rules.

To use the mailertable feature, you will need to do the following:

  1. Edit the mailertable file:

  2. The mailertable file is usually located in the /etc/mail directory.

  3. Open the mailertable file in a text editor and add a line for each domain that you want to route to a specific server or host. The line should have the following format:

domain.com mailer:server-or-host
  1. For example, to route all email for the example.com domain to the mail server at mx.example.com, you would add the following line to the mailertable file:
example.com mailer:mx.example.com
  1. Repeat this step for each domain that you want to route to a specific server or host.

  2. Generate the mailertable.db file:

  3. After modifying the mailertable file, you will need to generate a mailertable.db file from it. This can be done by running the following command:

sudo makemap hash
Created Time:2017-10-28 20:40:31  Author:lautturi