[olug] Postfix & dovecot

Lou Duchez lou at paprikash.com
Fri Oct 19 06:28:01 UTC 2012


Do you mean you're setting up a mail server for foo.com, bar.com, 
oob.com, and arf.com: so if I am sending an E-Mail to frank at foo.com, the 
E-Mail should be delivered to the server you're setting up, and should 
wait there so Frank can IMAP in and read it?

To handle the accepting of mail from any source, here's what you'd need 
in /etc/postfix/main.cf:

virtual_mailbox_domains = foo.com bar.com oob.com arf.com
smtpd_relay_restrictions = permit_sasl_authenticated 
reject_unauth_destination permit

As for Dovecot and IMAP (and I would guess you'll want to use Dovecot 
authentication for your Postfix SMTP relay), here's what works for me, 
based on the following design:

-    I've got a directory called /vmail .
-    E-Mail to frank at foo.com is stored under /vmail/Maildir/foo.com/frank .
-    I've got a text file called /vmail/passwords that lists my logins 
and passwords (the format will be specified below).
-    I've created users "dovecot" and "postfix" to run their respective 
utilities.
-    "dovecot" is UID 501 and GID 501.
-    There will be a socket called /vmail/passwordsocket that dovecot 
creates, so that postfix has a way to ask dovecot to validate logins and 
passwords.
-    This is by no means the best or most secure system out there.  I'm 
just trying to give you a simple thing to get the ball rolling.

In /etc/dovecot/dovecot.conf:

auth_mechanisms = plain login
disable_plaintext_auth = no
mail_location = maildir:/vmail/Maildir/%d/%n
userdb {
   args = /vmail/passwords
   driver = passwd-file
}
passdb {
   args = /vmail/passwords
   driver = passwd-file
}
service auth {
   unix_listener /vmail/passwordsocket {
     group = postfix
     mode = 0660
     user = postfix
   }
   user = dovecot
}


And in /etc/postfix/main.cf, you'd need the following:

virtual_mailbox_base = /vmail
home_mailbox = Maildir/
virtual_minimum_uid = 100
virtual_uid_maps = static:501
virtual_gid_maps = static:501
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /vmail/passwordsocket
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_alias_maps = hash:/etc/postfix/virtual
show_user_unknown_table_name = yes
inet_interfaces = all
myhostname = mail.foo.com



After that is the small matter of defining your mailboxes.  Your 
/vmail/passwords would contain lines that looked like:

frank at foo.com:{plain}frankspassword:dovecot:dovecot

And postfix would need entries set up in /etc/postfix/vmailbox that 
looked like:

frank at foo.com    foo.com/frank/

After any changes to /etc/postfix/vmailbox you'd need to run "postmap 
/etc/postfix/vmailbox".



I think this is just about right; I'm basing this on a configuration 
that I set up years ago, it has served me well, and I have since 
modified it to add assorted functionality.  Hopefully I have provided 
all the necessary nuts and bolts and haven't left anything out, IKEA style.




> How do I set postfix up to accept mail from any source for four
> different domains with no user diferentiation?  how do i set up
> dovecot to use passwd authentication and provide IMAP services for
> those users?
>
>
> Sam
>




More information about the OLUG mailing list