Mailserver with ldap tutorial – part 4: testing

After I’ve described how to set up a mailserver with openldap, postfix and dovecot it’s now time to test it and make sure everything works.

This is a post from my old blog It has been moved here and slightly edited for better readability. It's also been adjusted to the new layout.
The content however is old and might be outdated.

This is step 4 of the 8 step tutorial for setting up a mailserver with openldap, postfix and dovecot using virtual users. You can find the overview here.

After setting up all important parts of the mailserver it is high time to do some tests. The most important thing is to avoid creating an open relay which will allow everybody to send mail from your server, As spammers will use it your server will be listed on spam lists and your mails will be tagged as spam (or deleted). Depending on your legislation setting up an open relay might even be a crime. So take care!

As most errors will show up either in /var/log/syslog or /var/log/mail.log so you will want to keep an eye on them:

tail -f /var/log/syslog
tail -f /var/log/mail.log

A 1st test: starting up

To make sure all services are starting properly we restart them:

/etc/init.d/slapd restart
/etc/init.d/postfix restart
/etc/init.d/dovecot restart

I’ve sometimes experienced problems with restarting dovecot. It helps to stop it first and start again:

/etc/init.d/dovecot stop
/etc/init.d/dovecot start

A 2nd test: local delivery

Now we check if locally send mails are delivered correctly. You can send a mail locally by

echo "%%This is a test ..." | mail -s "Testmail"

You should find the mail in /var/vmail/ The same way you can test aliases.

A 3rd test: sending from outside

This is the most important step. You will need a computer different from your server.
First encode the credentials of the user to test in base64, eg:

perl -MMIME::Base64 -e 'print encode_base64("dummy@cbjck.deDummysPassword")'

You will get something like


Now open a telnet connection from your other computer to the server on port 25

telnet 25

The server will answer with its SMTP-Banner:

Trying cbjck,de…
Connected to cbjck,de.
Escape character is ‘^]’.
220 ESMTP Postfix (Debian/GNU)</pre>
This tells us that postfix is up and running. We now tell the server that we want to send a mail
<pre>EHLO localhost</pre>
and the server will offer ist abilities, something like the following - depending on your config.
250-SIZE 10240000
250 DSN

We choose AUTH PLAIN for login and use the credentials created before:


On success the server will tell something like

235 2.7.0 Authentication successful

We now can send a mail:

250 2.1.0 Ok
250 2.1.5 Ok
354 End data with .
Some Text
250 2.0.0 Ok: queued as 66808670597

You will want to repeat this using invalid credentials and using no login to make sure your server is safe.

Final test: IMAP

Use your prefered MUA (mail user agent) like Evolution, Thunderbird/Icedove, Apple Mail, …

Now our mailserver is ready for part 5: virus and spam protection.

Edited on Jan 9th 2015 for better readability.
Edited on Aug 20th 2017 for better readability.

Leave a Reply

Your email address will not be published. Required fields are marked *