Exim is an open source MTA that can be used as a drop-in replacement for Sendmail on Unix-like operating systems. I have no idea what’s the best mail server out there, but if you are looking for a relay-only server to install on your development setup, Exim is probably the easiest to get started with.
In this article I’ll show you how to configure Exim to send messages through Gmail.
Installing Exim
First we need to install Exim and its dependencies, which is a simple task in modern Linux distros like Ubuntu/Debian:
$ sudo apt-get install exim4
Configuring Exim as a relay server
There’s a wizard that helps us with the basic setup; run the following command line to open it and fill each screen as follows:
$ sudo dpkg-reconfigure exim4-config- General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail
- System mail name: yourdomain.com
- IP-addresses to listen on for incoming connections: 127.0.0.1 ; ::1
- Other destinations for which mail is accepted: Leave it blank
- Machines to relay mail for: Leave it blank
- Host name for the outgoing smarthost: smtp.gmail.com:587
- Hide local mail name in outgoing mail: Yes
- Visible domain name for local users: yourdomain.com
- Keep number of DNS-queries minimal: No
- Delivery method for local mail: mbox format in /var/mail/
- Split configuration into small files: Yes
- Root and postmaster mail recipient: Leave it blank
Now we have to configure the user credentials in the file /etc/exim4/passwd.client by adding the following line:
# Replace [username] and [password] by your account's credentials *.google.com:[username]:[password]
Let’s finish the configuration by running the following command line:
$ sudo update-exim4.confTesting the setup
Here’s an old-school way to test if our setup is working — with telnet command:
$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 localhost ESMTP Exim 4.71 Wed, 23 Jun 2010 22:28:56 -0300
HELO localhost
250 localhost Hello localhost [::1]
MAIL FROM: username@yourdomain.com
250 OK
RCPT TO: destination@email.com
250 Accepted
DATA
354 Enter message, ending with "." on a line by itself
SUBJECT: Message subject
Testing Exim via telnet. w00t!
.
250 OK id=1ORbG5-0005uh-EF
QUIT
221 localhost closing connection
Connection closed by foreign host.
Open the log files at /var/log/exim4 to see if the message relayed correctly. This is how a successful attempt looks like:
2010-06-23 22:29:47 1ORbG5-0005uh-EF <= local@yourdomain.com H=localhost [::1] P=smtp S=345 2010-06-23 22:29:50 1ORbG5-0005uh-EF => destination@email.com R=smarthost T=remote_smtp_smarthost H=gmail-smtp-msa.l.google.com [74.125.45.109] ..." 2010-06-23 22:29:50 1ORbG5-0005uh-EF Completed
If the log looks good and you didn’t get the message, it’s a good idea to check the spam box of the destination email before you change any configuration.
Posts em Português
Posts in English
Pingback: Tweets that mention Setting Up A Local Mail Server With Exim And Ubuntu | Destaqueblog -- Topsy.com