Working Mailserver. Postfix, Fetchmail, Procmail, Dovecot with Ubuntu 10.04
Thus is an update to my original mail server configuration post here and my update for 9.10 here
After upgrading the server to Lucid Lynx I couldn’t download my emails, Thunderbird gave the warning that it couldn’t connect to the server. After reading the logs I found that Dovecot no longer understood the line in etc/dovecot/dovecot.conf reading:
ssl_disable = yes
I commented the line out and everything seems to be ok.
There is a bug report here
Working Mailserver. Postfix, Fetchmail, Procmail, Dovecot with Ubuntu 9.10
Today I set up the mail server on my new server running Ubuntu 9.10. The Original mail server was running on Ubuntu 7.04 for many years, the configuration blog is here
The first difference I noticed was that Ubuntu have been working on a mail server stack that should work out of the box. You can download this with the package dovecot-postfix. I am sure this is the best bet for anyone starting from scratch and I will try it out when I get time but for now I wanted to install the stack and configuration I knew worked for me.
So I downloaded Postfix, Fetchmail, Procmail, Dovecot.Postfix and copied my configuration files from the old server. The only differences were in the file /etc/dovecot/dovecot.conf
and were:
mail_extra_groups
has been deprecated and you should now use mail_access_groups
or mail_privileged_group
instead if you need this. As it happens I commented it out and haven’t had a problem. I think it is only relevant when you use mboxes and I don’t.
default_mail_env = maildir:/home/%u/Maildir/
has also been deprecated and you should use
mail-location = maildir:/home/%u/Maildir/
instead.
IMPORTANT the configuration file /etc/dovecot/dovecot-postfix.conf
has precedence over /etc/dovecot/dovecot.conf
so if you want to use /etc/dovecot/dovecot.conf
you have to rename /etc/dovecot/dovecot-postfix.conf
.
For problems after upgrading to 10.04 please look here
Working Mailserver. Postfix, Fetchmail, Procmail, Dovecot
To clarify the aim of this project, I was trying to set up a mailserver which will retrieve my emails from the ISP and then distribute them locally according to the name in the To: header. My ISP allows me to use several “aliases” therefore mail for me has stephen.young@ISP.com and mail for my wife has barbara.young@ISP.com in the To: header even though my account is fred.young@ISP.com. This little project turned out to be very difficult because the configuration information for the various components was scattered about and there is also a lot of wrong configuration info out there. After a few days googling I managed to get the server to filter Barbara’s emails and put them in a directory that was reachable by her Outlook client.
I used Postfix, Fetchmail, Procmail and Dovecot to make this work.
Postfix: This was the easiest part, I installed Postfix, added the line home_mailbox = Maildir/
in /etc/postfix/main.cf
to make postfix use Maildir as opposed to Mbox and added the LAN address to “mydestination
” and it just worked. Here is my Postfix config file.
# appending .domain is the MUA's job.
append_dot_mydomain = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
myhostname = localhost
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localhost.localdomain, localhost
relayhost = smtp.isp.com
mynetworks = 127.0.0.0/8, 192.168.0.0/24
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/
inet_protocols = all
Fetchmail: I added lines to .fetchmailrc make fetchmail send its output to Procmail. The .fetchmailrc resides in my $HOME directory, here is a copy.
server pop.isp.com
proto pop3
user fred.smith
password nottelling
mda 'procmail -f-'
mda "/usr/bin/procmail -d %s" # tell fetchmail which MDA to use
Procmail: The .procmailrc file also lives in my $HOME directory. There are two important points here:
1) don’t forget the trailing “/” in the directory names as it informs Procmail to use Maildir format.
2) The UMASK=007
is essential in order to make the moved mails readable by the group. Procmail automatically makes the owner the user using Procmail and sets the permission to owner only! The .procmailrc is here.
UMASK=007
PATH=/usr/bin:/usr/local/bin
MAILDIR=$HOME/Maildir/
DEFAULT=$HOME/Maildir/steve/
LOGFILE=$HOME/procmail.log
SHELL=/bin/sh
# Put mail for barbara into mailbox barbara
:0:
* ^To:.*barbara.young
/home/barbara/Maildir/barbara/
Dovecot: There is some good information at the Dovecot WiKi http://wiki.dovecot.org/ but unfortunately it is hard to find as the site seems more interested in showing you how to use a Wiki than making it easy to navigate through the Dovecot information. In the Dovecot configuration file /etc/dovecot/dovecot.conf
make sure that:
1) listen = *
or the IP address of your LAN, ie “listen = 192.168.0.0/24, localhost”.
2) ssl_disable = yes
at least for the setup phase. I intend to set up ssl etc now that I have everything working but getting it working was my first priority. Here is the confiuration file
protocols = pop3 pop3s
listen = *
ssl_disable = yes
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_extra_groups = steve
default_mail_env = maildir:/home/%u/Maildir/%u
protocol pop3 {
login_executable = /usr/lib/dovecot/pop3-login
mail_executable = /usr/lib/dovecot/pop3
pop3_enable_last = no
pop3_uidl_format = %08Xu%08Xv
}
auth default {
mechanisms = plain
passdb pam {
}
userdb passwd {
}
user = root
}
plugin {
}
Now it’s working but I will have to study the SSL features to make it really safe.
**NOTE** I have recently updated this for Ubuntu 9.10, Karmic Koala. The post about this is here
Mail Server / Postfix, Fetchmail, Dovecot
I’m busy at the moment trying to build a small mailserver so that I can seperate Barbaras emails from my own and make hers available to Outlook on her M$ Laptop. I will report how I got it working when I get it working.