Setting Up A Local Mail Server With Exim And Ubuntu

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
  1. General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail
  2. System mail name: yourdomain.com
  3. IP-addresses to listen on for incoming connections: 127.0.0.1 ; ::1
  4. Other destinations for which mail is accepted: Leave it blank
  5. Machines to relay mail for: Leave it blank
  6. Host name for the outgoing smarthost: smtp.gmail.com:587
  7. Hide local mail name in outgoing mail: Yes
  8. Visible domain name for local users: yourdomain.com
  9. Keep number of DNS-queries minimal: No
  10. Delivery method for local mail: mbox format in /var/mail/
  11. Split configuration into small files: Yes
  12. 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.conf

Testing 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.

Sobre Daniel Martins

Fundador da Destaquenet, ele é graduado em Sistemas de Informação e desenvolve softwares como hobby e profissão desde 2000. Especializado na plataforma Java, ele utiliza a tecnologia há vários anos, sendo programador e desenvolvedor web certificado pela Sun Microsystems, recentemente adquirida pela Oracle. Também se interessa por assuntos ligados à cultura open source, metodologias ágeis, engenharia de software, frameworks e linguagens dinâmicas tais como Python, Ruby e Smalltalk.
Esta entrada foi publicada em English, Tutorials e marcada com a tag , , , , , , , , , , , . Adicione o link permanente aos seus favoritos.

Uma resposta a Setting Up A Local Mail Server With Exim And Ubuntu

  1. Pingback: Tweets that mention Setting Up A Local Mail Server With Exim And Ubuntu | Destaqueblog -- Topsy.com

Deixe um Comentário

O seu endereço de email não será publicado Campos obrigatórios são marcados *

*

Você pode usar estas tags e atributos de HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">