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- begin rewrite
- *@* [email protected] Ffr
This example matches all the address in your local field (*@*) and replaces the From envelope and From: fields with [email protected]. 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- 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- 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- exim -v [email protected]
- From: [email protected]
- Subject: Testing
- This a exim test message.
- ^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- 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- exim -bp
- // or
- mailq
Remove a particular message from the queue:
Show Plain Text- exim -Mrm {message-id}
Remove all messages from the mail queue:
Show Plain Text- exim -bp | exiqgrep -i | xargs exim -Mrm
Thanks, useful article.