John will surely prefer to read his mail in a comfortable mail program. So he needs a way to get access to his mailbox. Two protocols come into play here:
- POP3 (Post Office Protocol) is a simple protocol that lets you fetch email from a single mailbox. It is usually used to collect all emails, though you can also leave them on the server but this is a bit of a hack and you can't create multiple folders on the server to sort your mail. It saves space on the mail server because the email gets moved to the user's hard disk on their computer. But they won't be able to access the same email from another computer. Besides you cannot create multiple folders on the server to sort your mail. There is just the inbox. This variant is antiquated and not exactly user-friendly.
- IMAP (Internet Messaging Application Protocol) is predominantly focused upon leaving your mail on the server but you can also collect it like POP3. The inbox is where your incoming emails are stored but users can also maintain folders and move emails to them. But users can move emails to different directories. IMAP is useful when you want to access your email from different locations without losing mail because you fetched it from another location. The drawback is that lazy users leave their mail on the server thus filling up your server's hard disk (unless you use quotas).
Testing POP3
Let us establish a POP3 connection and retrieve John's email:
$> telnet localhost pop3
The server replies:
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. +OK Dovecot ready.
Login as John:
user john@example.com
The server should accept that:
+OK
Send the password:
pass summersun
The server should recognize the correct password:
+OK Logged in.
Get a list of John's emails:
list
Dovecot will tell you that one email is in the mailbox:
+OK 1 messages: 1 474 .
Fetch that email number 1:
retr 1
Dovecot sends you the email:
+OK 474 octets
Return-Path: <steve@example.com>
X-Original-To: john@example.com
Delivered-To: john@example.com
Received: from example.com (localhost [127.0.0.1])
by ... (Postfix) with ESMTP id 692DF379C7
for <john@example.com>; Fri, 18 May 2007 22:59:31 +0200 (CEST)
Message-Id: <...>
Date: Fri, 18 May 2007 22:59:31 +0200 (CEST)
From: steve@example.com
To: undisclosed-recipients:;
Hi John,
just wanted to drop you a note.
.
Close the connection to the POP3 server:
quit
The server will disconnect you:
+OK Logging out. Connection closed by foreign host.
Of course users won't use TELNET to read their mail. He will use a more comfortable email client. This is just to show you how POP basically works and to make sure Dovecot is behaving correctly.
Test IMAP
Instead of going through the following procedure (IMAP is rather complicated) you may as well just use mutt to create an IMAP connection:
$> mutt -f imap://john@example.com@localhost
Alternatively you can open up a raw IMAP connection to the server and enter the IMAP commands yourself:
$> telnet localhost imap2
You should get a connection:
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. * OK Dovecot ready.
IMAP commands always start with a number and reply to that command with the same number. So the following commands must be entered with the number at the beginning of each line. Login with username and password:
1 login john@example.com summersun
Dovecot logs you in:
1 OK Logged in.
Ask Dovecot for a list of John's mail folders:
2 list "" "*"
Here comes the list:
* LIST (\HasNoChildren) "." "INBOX" 2 OK List completed.
Select your inbox:
3 select "INBOX"
Dovecot gives you all kinds of information about that folder:
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft) * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted. * 1 EXISTS * 0 RECENT * OK [UIDVALIDITY 1180039205] UIDs valid * OK [UIDNEXT 3] Predicted next UID 3 OK [READ-WRITE] Select completed.
You see that one email exists. Fetch it:
4 fetch 1 all
IMAP will just give you basic information on the email:
* 1 FETCH (FLAGS (\Seen) INTERNALDATE ......... 4 OK Fetch completed.
To read the actual mail body you need to fetch it explicitly:
5 fetch 1 body[]
Here it comes:
* 1 FETCH (BODY[] {474}
Return-Path: <steve@example.com>
X-Original-To: john@example.com
Delivered-To: john@example.com
Received: from example.com (localhost [127.0.0.1])
by ... (Postfix) with ESMTP id 692DF379C7
for <john@example.com>; Fri, 18 May 2007 22:59:31 +0200 (CEST)
Message-Id: <...>
Date: Fri, 18 May 2007 22:59:31 +0200 (CEST)
From: steve@example.com
To: undisclosed-recipients:;
Hi John,
just wanted to drop you a note.
)
5 OK Fetch completed.
Disconnect from the server:
6 logout
Dovecot logs you out:
* BYE Logging out 6 OK Logout completed. Connection closed by foreign host.
POP3 and IMAP appear to work. You could now use any email program like Kmail, Evolution or Thunderbird/Icedove and set up a POP3 or IMAP email account. The quickest way to check encrypted connections is using mutt again:
$> mutt -f imaps://john@example.com@localhost
If you use other mail programs note that the username will be the email address 'john@example.com' and the password is 'summersun'. You can try these kinds of connections:
- POP3
- IMAP
- POP3 with TLS/SSL enabled
- IMAP with TLS/SSL enabled
When using TLS/SSL you will probably get a warning that the certificate of the server cannot be trusted. Dovecot creates a self-signed certificate. If you are not happy with the certificate then create your own:
$> openssl req -new -x509 -days 3650 -nodes -out /etc/ssl/certs/dovecot.pem \
-keyout /etc/ssl/private/dovecot.pem
The certificate and key will be created while you get asked a few questions:
Generating a 1024 bit RSA private key .........++++++ ............................++++++ writing new private key to '/etc/ssl/certs/dovecot.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:DE State or Province Name (full name) [Some-State]:Hamburg Locality Name (eg, city) []:Hamburg Organization Name (eg, company) [Internet Widgits Pty Ltd]:workaround email service Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:mailtest.workaround.org Email Address []:postmaster@workaround.org
Of course you should fill in your own information here. The most important setting is the Common Name which must contain the fully-qualified name of your mail server. Oh, and this certificate will be valid for 10 years (3650 days) - adjust that period as you want.
Do not forget to set the permissions on the private key so that no unauthorized people can read it:
$> chmod o= /etc/ssl/private/dovecot.pem
And you will have to restart Dovecot to make it read your new certificate:
$> /etc/init.d/dovecot restart
25 Comments
dovecot Can't load private key file /etc/ssl/private/dovecot.key
Submitted by Anonymous (not verified) on
Whether you call the private
Submitted by Christoph Haas on
cant login via pop3 or imap
Submitted by Anonymous (not verified) on
logging in per mutt works perfectly, but i can't log in per pop3 or imap. any idea what i did wrong?
console says:
telnet localhost pop3
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
john@example.com
-ERR Unknown command.
user john@example.com
+OK
pass summersun
+OK Logged in.
-ERR Internal error occurred. Refer to server log for more information. [2010-02-25 16:29:32]
Connection closed by foreign host.
log:
Feb 25 16:20:01 servername postfix/qmgr[7562]: BD1F5BCE87E3: removed
Feb 25 16:29:32 servername dovecot: auth-worker(default): mysql: Connected to 127.0.0.1 (mailserver)
Feb 25 16:29:32 servername dovecot: pop3-login: Login: user=<john@example.com>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
Feb 25 16:29:32 servername dovecot: POP3(john@example.com): open(/var/vmail/example.com/john/Maildir/cur/1267101080.25858_2.lvps83-169-34-252:2,RS) failed: Permission denied
Feb 25 16:29:32 servername dovecot: POP3(john@example.com): Couldn't init INBOX: Internal error occurred. Refer to server log for more information. [2010-02-25 16:29:32]
Feb 25 16:29:32 servername dovecot: POP3(john@example.com): Mailbox init failed top=0/0, retr=0/0, del=0/0, size=0
Thanks for help,
Jens
Permissions?
Submitted by Christoph Haas on
This looks suspiciously like you missed to set proper directory permissions somewhere in /var/vmail.
still
Submitted by Anonymous (not verified) on
First of all thanks for the great tutorial, and the fast reply!
i'm sorry that i have to say that i still was not able to solve the problem.
i even deleted the vmail user and set it up with a different id, but sitll the same error.
do you have an other hint for me?
thanks a 1000 times,
jens
mutt works, but not evolution or kmail
Submitted by Anonymous (not verified) on
When I use mutt or telnet, I can read the emails correctly,
but using a common email program, I always get an error:
-ERR, Authentication failed, or similar.
Authentication
Submitted by Anonymous (not verified) on
First of all, let me say this is a great tutorial! Unlike others, I have been able to suceed to a certain level. my problem is that I'm failing to authenticate, I get the following error message while using Telnet "Temporary authentication failure." and the same goes for Evolution.
I know its probably a misconfiguration somewhere, I have double-checked my MD5 passwords. Could you possibly point me to where I could have mistyped or made an error
Logs say more than words :)
Submitted by Christoph Haas on
Thanks for the praise. :)
Please check your /var/log/mail.log for obvious signs of irregularity. I have a good feeling you will find something there.
THANKS A MILLION
Submitted by Anonymous (not verified) on
You must think I'm stupid! I had mistyped password (passwrod) - my mail server is up - I am using Ubuntu and RoundCube for webmail - I'm so happy... Let me continue with the tutorial. This is wonderful...
Fatal: Plugin cmusieve not found ...
Submitted by Anonymous (not verified) on
Just a little tip for the guys out there already using Debian Squeeze (currently testing):
Trying to send the test mail, I first got the following error in /var/vmail/dovecot-deliver.log:
Fatal: Plugin cmusieve not found from directory /usr/lib/dovecot/modules/lda
The reason seems to be that a plugin was renamed; in the /etc/dovecot/dovecot.conf, write:
protocol lda {
[...]
mail_plugins = sieve
}
rather than cmusieve. This worked for me. Now I can continue setting my server up. Many, many thanks for this terrific tutorial, Christoph!
User Password Error
Submitted by Anonymous (not verified) on
Hi what an outstanding tutorial. I am a real newbie to Linux.
And am amazed as to how far I have been able to progress. Getting to the point where
I am trying to get the pop3 to work..
Thanks to your great tutorials...
I was ablle to read the email sent to john@example.com using mutt.
When I try and telnet to the pop3 everything works as shown until i enter the password "summersun"
I then get a user authentication error and the following message in the mail.err log:-
May 10 21:30:37 debianLenny dovecot: auth-worker(default): sql(john@example.com,127.0.0.1): Unknown
password scheme PLAIN-MDS
It seems as if its the encryption which is not setup correctly?
I tried deleting john@example.com and re entered and resent the email.. but still get the same problem.
Hope you can point me in the right direction
Thanks in advance
User Password error - mail log
Submitted by Anonymous (not verified) on
May 10 21:29:51 debianLenny dovecot: auth-worker(default): mysql: Connected to 127.0.0.1 (mailserver
)
May 10 21:29:51 debianLenny dovecot: auth-worker(default): sql(john@example.com,127.0.0.1): Unknown
password scheme PLAIN-MDS
May 10 21:30:37 debianLenny dovecot: auth-worker(default): sql(john@example.com,127.0.0.1): Unknown
password scheme PLAIN-MDS
May 10 21:32:14 debianLenny dovecot: pop3-login: Aborted login (2 authentication attempts): user=<jo
hn@example.com>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
debianLenny:/var/vmail/example.com/john/Maildir#
MDS? MD5!
Submitted by Christoph Haas on
Try MD5 instead of MDS. :)
MDS MD5
Submitted by bspark (not verified) on
grep
Submitted by Christoph Haas on
Try
grep MDS /etc/dovecot/*
to see where the typo is.
MDS - MD5
Submitted by Anonymous (not verified) on
THanks for that.... solved that problem..
Cheers
extracting and installing the ssl cert on mail client
Submitted by Anonymous (not verified) on
Hi,
Thanks for the great document.
Is there a way to download the ssl cert and install it in outlook express or entourage so that I don't have to hit 'yes' to the cert warning to get the mail?
Thanks,
R
Great work, only one problem with OL2003
Submitted by Anonymous (not verified) on
Thank you for this great work around. It works perfectly for the most clients. Only OL2003 clients are unable to send email. All clients can read email. Mail for Mac --> all OK Thunderbird for Mac/win --> all OK OL2007 --> all OK Squirrelmail --> all OK OL2003 --> only reading, sending: 554 5.7.1: Relay access denied I don't know what it is. If any body has an idea, I will thankfull for every help. mamo
Logs?
Submitted by Christoph Haas on
Check your log files for more detailed information. It should tell you the actual reason.
Help! pop3 not working
Submitted by Anonymous (not verified) on
HellO! great job excelent tutorial!
Im having some trouble with pop3. It does not recognize the paswiord.
Log doesnt help much al leat for me...
dovecot : pop3-login: Aborted login (1 authentication attempts): user=<test@domain.com>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
Please help, is there any variable or something that might be wrong.
I already check the user and the password, but both of them are corect.
Thanks!
Password authentication
Submitted by Anonymous (not verified) on
I got some big problems.
I already haye a mysql database... The passwords are encrypted but im not sure of the mechanism, im almost sure it is password()
Is there any way i can use this mysql password function to authenticate with dovecot?
Thks
Erro at login on imap
Submitted by Anonymous (not verified) on
if I try "mutt -f imap://webmaster@example.de@localhost", I get the following Error with the Password form my
MySQL : login failed
if I try it with "telnet localhost imap2", I get "1 NO [AUTHENTICATIONFAILED] Authentication failed."
I controll my configs and everything is like in the Tutorial. My Password I copy form MySQL to telnet.
wh thanks
P.S. The tutorial is super
Solved
Submitted by Anonymous (not verified) on
the PLAIN-MD5 was it. I have to make an MD5-hash from the Password
Remote authentication problem
Submitted by Anonymous (not verified) on
Hi your tuto is super, i'm just getting a problem with remote auth :
when i try mutt -f imap://user@example.com@localhost on the server i am able to read the user's mails
when i try the same command from a remote client, the password is rejected.
I have no iptables running...
Sending mail with telnet ... 25 is working with user@example.com
i'm facing the problem with all users
I don't see anything clear in the log files :
dovecot: imap-login: Aborted login (3 authentication attempts): user=<user>, method=PLAIN, rip=192.168.10.100, lip=192.168.10.200
Have any idea ?
dovecot --version : 1.0.15
thanks in advance
thanks for this great
Submitted by Anonymous (not verified) on
thanks for this great tutorial! it's the best i have read, really explaining it in a good way. you are a good person!
still having problems logging in remotely via telnet or mutt (error log doesn't show a clear reason) but i will google it tomorrow.