How to get exim running as your MTA with a smarthost

If you need to configure exim 4 as your default MTA (mail transport agent) with an external smart host (SMTP) server then these instructions might help. This setup expect that the SMTP server requires no authentication. I've also tagged on some useful commands for clearing your mail.

Installing

After installing exim with yum install exim you will need to setup your smarthost (smtp relay) server in the /etc/exim/exim.conf file.

Setup

Simply comment out the dnslookup section and add these lines below that section :-

divertnonlocal:
driver = manualroute
domains = ! +local_domains
transport = remote_smtp
route_list = * 
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
no_more

Thats it, however depending on how your server has been setup you may need to set some rewrite option to mask some of your email addresses so that they are accepted by your local SMTP smart host, you can set these in the configuration files rewrite section, for example :-

Show Plain Text
Text code
  1. begin rewrite
  2. *@* your.address@your.domain Ffr

This example matches all the address in your local field (*@*) and replaces the From envelope and From: fields with your.address@your.domain. For more in-depth options check out the Exim Address rewriting section .

Setting your MTA

From your bash shell you can also set exim as your default MTA by running the following command and selecting exim from the menu :-

Show Plain Text
Text code
  1. alternatives --config mta

For those running Debian or Ubuntu life has been made easy with the utility dpkg-reconfigure, just run the following command and follow the menu's :-

Show Plain Text
Text code
  1. dpkg-reconfigure exim4-config

Testing Exim

To manually test that your exim has been installed correctly you can use the following command :-

Show Plain Text
Text code
  1. exim -v your.address@your.domain
  2. From: your.server@your.domain
  3. To: your.address@your.domain
  4. Subject: Testing
  5. This a exim test message.
  6. ^D

With the -v option you will get allot of debug information that may assist in any local or SMTP server mail delivery problems.

Errors

If your getting an error similar to the following :

Show Plain Text
Text code
  1. R=send_to_relay T=remote_smtp defer (-42): authentication required but server did not advertise AUTH support

With the above error its possible that your server does not require or has not got authentication installed. Just remove the hosts_require_auth=* lines from the remote_smtp section.

Some useful mail commands

List all messages in the mail queue:

Show Plain Text
Text code
  1. exim -bp
  2. // or
  3. mailq

Remove a particular message from the queue:

Show Plain Text
Text code
  1. exim -Mrm {message-id}

Remove all messages from the mail queue:

Show Plain Text
Text code
  1. exim -bp | exiqgrep -i | xargs exim -Mrm
Filed under: Linux  Tags: Redhat, Debian, Ubuntu

1 Responses to “How to get exim running as your MTA with a smarthost”

Thanks, useful article.

Sorry, comments have been closed for this post.