After I’ve described how to set up a mailserver with
dovecot it’s now time to test it and make sure everything works.
The content however is old and might be outdated.
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/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" email@example.com
You should find the mail in
/var/vmail/cbjck.de/dummy/. 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
perl -MMIME::Base64 -e 'print encode_base64("firstname.lastname@example.orgDummysPassword")'
You will get something like
Now open a
telnet connection from your other computer to the server on port 25
telnet cbjck.de 25
The server will answer with its SMTP-Banner:
Trying cbjck,de… Connected to cbjck,de. Escape character is ‘^]’. 220 cbjck.de 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. <pre>250-lvpsxxx-xxx-xxx-xxx.dedicated.hosteurope.de 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-STARTTLS 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN
AUTH PLAIN for login and use the credentials created before:
AUTH PLAIN bXVzdGVyLmRlTWVpblNNVFBQYXNzd29ydA==
On success the server will tell something like
235 2.7.0 Authentication successful
We now can send a mail:
MAIL FROM email@example.com 250 2.1.0 Ok RCTP TO firstname.lastname@example.org 250 2.1.5 Ok data 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.