Configuring Exim4 as a Dreamhost SMTP relay

From Fyzix
Jump to: navigation, search

Use case - Say you want to relay email from your Linux server through your Dreamhost mail server.

For Debian and Ubuntu systems using the apt-get packager manager.

Please note, this is not an officially sanctioned practice at Dreamhost.

Installation

apt-get install -y exim4-base exim4-config exim4-daemon-light libmailutils4 mailutils mutt

Configuration

Run the following:

dpkg-reconfigure exim4-config

1. Choose mail sent by smarthost; no local mail

2. Type System Mail Name: e.g. yourdreamhostdomain.com

3. Type IP Adresses to listen on for incoming SMTP connections: 127.0.0.1 ; ::1

4. Leave Other destinations for which mail is accepted blank

5. Visible domain name for local users: subdomain.yourdreamhostdomain.com or yourdreamhostdomain.com

6. IP address or host name of the outgoing smarthose: mail.yourdreamhostdomain.com::587

7. Keep number of DNS-queries minimal (Dial-on-Demand)? No

8. Split configuration into small files? Yes

30_exim4-config_examples

Modify /etc/exim4/conf.d/auth/30_exim4-config_examples and uncomment the following:

 plain_server:
   driver = plaintext
   public_name = PLAIN
   server_condition = "${if crypteq{$auth3}{${extract{1}{:}{${lookup{$auth2}lsearch{CONFDIR/passwd}{$value}{*:*}}}}}{1}{0}}"
   server_set_id = $auth2
   server_prompts = :
   .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
   server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
   .endif

Don't worry about the plaintext. We will address that next to insure encrypted authentication.

01_exim4-config_listmacrosdefs

Modify /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs

At the end of the file input

MAIN_TLS_ENABLE = true

Modify /etc/exim4/passwd.client and input

mail.yourdreamhostdomain.com:user@yourdreamhostdomain.com:S0m3S3cur3P4ssW0rd

Update/Restart exim4

update-exim4.conf
service exim4 restart

Testing

Open two terminals.

On the first terminal tail the exim4 mail log in real time.

tail -f /var/log/exim4/mainlog

Send a test email through the relay

echo "test" | mail -s "subject" your@receivingemailaddress.com

If successful, you should see something to the effect of:

2015-04-12 21:33:47 1YhTFz-0001wW-1u <= root@yourdreamhostdomain.com U=root P=local S=480
2015-04-12 21:33:48 1YhTFz-0001wW-1u => your@receivingemailaddress.com R=smarthost T=remote_smtp_smarthost H=mail.fyzix.net [208.97.132.208] X=TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128 DN="C=US,postalCode=92821,ST=California,L=Brea,STREET=417 Associated Rd,O=Dreamhost Web Hosting,OU=admins,OU=Provided by New Dream Network\, LLC,OU=DreamHost Premium Wildcard SSL,CN=*.mail.dreamhost.com"
2015-04-12 21:33:48 1YhTFz-0001wW-1u Completed

Plus the email should arrive at the receiving email address.