Dovecot basic

From wikipost
Revision as of 12:57, 24 April 2014 by Admin (talk | contribs) (IMAP sync with Gmail)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Dovecot basic

  • dovecot-imapd
  • exim4
  • fetchmail


apt-get install dovecot-imapd exim4 fetchmail

setting up exim

dpkg-reconfigure exim4-config

General type of mail configuration: internet site

System mail name: mydomain.com

IP-addresses to listen on for incoming SMTP connections: No value (all interfaces)

Other destinations for which mail is accepted: mydomain.com

Domains to relay mail for: No value (no other domains)

Machines to relay mail for: No value (no other machines)

Keep number of DNS-queries minimal (Dial-on-Demand)? No

Delivery method for local mail: Maildir format in home directory

Split configuration into small files? Yes



setting up dovecot

create a new file /etc/dovecot/passwd

test:{PLAIN}pass
bill:{PLAIN}secret
timo@example.com:{PLAIN}hello123
dave@example.com:{PLAIN}world234
joe@elsewhere.org:{PLAIN}whee
jane@elsewhere.org:{PLAIN}mypass

To store passwords encypted, use:

doveadm pw -s ssha
Enter new password: foo
Retype new password: foo
{SSHA}DNODS3ZrOq1bu2MasNk79LxHhlU9iI03

Note that you won't get the same output after {SSHA} as above, because Dovecot uses random salts when creating the SSHA hash. This means that even if multiple users have the same password, you won't know that because their hashes are different.

The passwd file entry would be:

bill:{SSHA}DNODS3ZrOq1bu2MasNk79LxHhlU9iI03


With the 2.x versions of Dovecot the configuration files have been split up (as opposed to a single dovecot.conf file in 1.x versions).

Below are listed the modifications required on the default dovecot config files (after a fresh installation).

  • /etc/dovecot/dovecot.conf

Leave as-is.


  • /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain
!include auth-system.conf.ext


  • /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir


  • /etc/dovecot/conf.d/auth-passwdfile-conf.ext
passdb {
   driver = passwd-file
   args = /etc/dovecot/users
}

userdb {
   driver = passwd-file
   args = uid=vmail gid=vmail home=/home/vmail/%u
}









setting up fetchmail

~/.fetchmailrc

poll localhost with proto POP3
user abc@xyz.org
pass bill123
is yyy@gmail.com here


IMAP sync with Gmail

apt-get install offlineimap


  • offlineimaprc example
[general]
accounts = Gmail
maxsyncaccounts = 1

[Account Gmail]
localrepository = Local
remoterepository = Remote
maxage = 365

[Repository Local]
sep = /
type = Maildir
localfolders = /disk/mail/dovecot/varvmail/mydomain.com/gmail/Maildir
nametrans = lambda folder: re.sub('Junk', '[Gmail].Spam',
                           re.sub('Drafts', '[Gmail].Drafts',
                           re.sub('Inbox', '[Gmail].INBOX',
                           re.sub('Trash', '[Gmail].Bin',
                           re.sub('Sent', '[Gmail].Sent Mail',
                           re.sub('Flagged', '[Gmail].Starred',
                           re.sub('Trash', '[Gmail].Trash',
                           re.sub('Important', '[Gmail].Important',
                           re.sub('Archive', '[Gmail].All Mail', folder)))))))))

[Repository Remote]
type = Gmail
remotehost = imap.gmail.com
remoteuser = my.email.address@gmail.com
remotepass = mypassword
ssl = yes
maxconnections = 3
realdelete = no
## One-way synching.  Perfect for backups.
readonly = true
nametrans = lambda folder: re.sub('.*Spam$', 'Junk',
                           re.sub('.*Drafts$', 'Drafts',
                           re.sub('.*INBOX$', 'Inbox',
                           re.sub('.*Sent Mail$', 'Sent',
                           re.sub('.*Starred$', 'Flagged',
                           re.sub('.*Trash$', 'Trash',
                           re.sub('.*Bin$', 'Trash',
                           re.sub('.*Important$', 'Important',
                           re.sub('.*All Mail$', 'Archive', folder)))))))))


Usage:

host#~: offlineimap -c offlineimaprc

Afterwards I reassign vmail as owner and group to all folders to be sure that messages are not left as root:root.

host#~: chmod -R vmail:vmail /disk/mail/dovecot/varvmail