Professional Documents
Culture Documents
Virtualization Poll
V irtual U s ers A nd
D omains With
P os tfix, C ourier,
M ySQ L A nd
SquirrelM ail
(U buntu 8 .0 4
L T S) (5 2 4 .9 M B)
(0 5 /1 5 /2 0 0 8 )
V M ware I mage
I mport G uide
L is t of all V M ware
I mages
Free Support
P aid Support
Navigation
H owtos
L inux
C entO S
D ebian
Fedora
Kernel
M andriva
P C LinuxO S
SuSE
U buntu
A pac he
Bac kup
1 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
C ontrol P anels
DNS
D es ktop
E mail
A nti-Spam/V irus
P os tfix
P roc mail
Sendmail
FT P
H igh-A vailability
L ighttpd
M onitoring
M ySQ L
P rogramming
C /C ++
P HP
Samba
Sec urity
A nti-Spam/V irus
V irtualization
O ther
FreeBSD
C ommerc ial
M ini-H owtos
Forums
C ontribute
Subs c ription
L ogin
Site M ap/RSS Feeds
User login
U s ername:
P as s word:
Remember M e?
Ads by Google
Free Domains
Postf ix
Conf igure Exim
Qmail Amav is
Who's online
2 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
HowtoForge Forums
Sell C vv G ood and
fres h, pleas e
purc has e my :X
s ell C vv G ood and
fres h, pleas e
purc has e my :X
how to run
inotifywait
bac kground
Res tarting O penBSD
Sec ure Shell
s erver s s hd
L inux ldap bind
windows ad
L dap from windows
to linux
pos tfix/s quirrelma
il with plugin ...
G odaddy and
N ames ervers
H ow to Run a V ideo
at the s tart
unattended?
L oc al T es ting
Server Setup
News
D is tro Review: O penSU SE 1 1 .2
KD E C ommunity Forums A nnounc e the C ontinuation of Klas s room
D RM C hange C ontinues T o C aus e D ebate
T he P erfec t D es ktop - Fedora 1 2 i6 8 6 (G N O M E )
Stream mus ic wireles s ely us ing P uls eA udio s erver
M us ic A lbum C overs A nd P ic ture P reviews A s Folder T humbnails I n N autilus
L inux M int 8 final releas ed
Finding files and doc uments with Rec oll
When O pen Sourc e M eets C los ed M inds
Strange I deas A bout Freedom of Speec h
more
Recent comments
boot problem after ins tall php5 pakage
1 4 hours 5 1 min ago
T hanks man
1 4 hours 5 8 min ago
3 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
Newsletter
Subscribe to
HowtoForge
Newsletter
and s tay informed
about our lates t
H O WT O s and
projec ts .
enter email address
Syndicate
You are here: Home » Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Ubuntu 8.04 LTS) » Virtual Users And
4 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
Domains With Postfix, Courier, MySQL And SquirrelMail (Ubuntu 8.04 LTS) - Page 2
Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Ubuntu
8.04 LTS) - Page 2
vi /etc/mysql/my.cnf
[...]
bind-address = 127.0.0.1
[...]
/etc/init.d/mysql restart
Run
5 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
vi /etc/postfix/mysql-virtual_domains.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT domain AS virtual FROM domains WHERE dom
hosts = 127.0.0.1
vi /etc/postfix/mysql-virtual_forwardings.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT destination FROM forwardings WHERE sourc
hosts = 127.0.0.1
vi /etc/postfix/mysql-virtual_mailboxes.cf
6 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/'
hosts = 127.0.0.1
vi /etc/postfix/mysql-virtual_email2email.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT email FROM users WHERE email='%s'
hosts = 127.0.0.1
vi /etc/postfix/mysql-virtual_transports.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT transport FROM transport WHERE domain='%
hosts = 127.0.0.1
7 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
vi /etc/postfix/mysql-virtual_mailbox_limit_maps.cf
user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT quota FROM users WHERE email='%s'
hosts = 127.0.0.1
T hen c hange the permis s ions and the group of thes e files :
chmod o= /etc/postfix/mysql-virtual_*.cf
chgrp postfix /etc/postfix/mysql-virtual_*.cf
N ow we c reate a us er and group c alled vmail with the home direc tory /home/vmail. T his is where all
mail boxes will be s tored.
N ext we do s ome P os tfix c onfiguration. Go sur e that y ou r epl ac e ser v er 1 .ex ampl e.c om w i th a v al i d FQDN ,
other w i se y our Postf i x mi ght not w or k pr oper l y !
8 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
A fterwards we c reate the SSL c ertific ate that is needed for TLS:
cd /etc/postfix
openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform
PEM -days 365 -x509
Country Name (2 letter code) [AU]: <-- Enter y our Countr y N ame (e.g., "DE").
State or Province Name (full name) [Some-State]: <-- Enter y our State or Pr ov i nc e N ame.
Locality Name (eg, city) []: <-- Enter y our Ci ty .
Organization Name (eg, company) [Internet Widgits Pty Ltd]: <-- Enter y our Or gani zati on N ame (e.g., the
name of y our c ompany ).
Organizational Unit Name (eg, section) []: <-- Enter y our Or gani zati onal U ni t N ame (e.g. "IT Depar tment").
Common Name (eg, YOUR name) []: <-- Enter the Ful l y Qual i f i ed Domai n N ame of the sy stem (e.g.
"ser v er 1 .ex ampl e.c om").
Email Address []: <-- Enter y our Emai l A ddr ess.
chmod o= /etc/postfix/smtpd.key
Firs t run
mkdir -p /var/spool/postfix/var/run/saslauthd
T hen edit /etc/default/saslauthd. Set START to yes and c hange the line OPTIONS="-c -m /var/run
/saslauthd" to OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r":
9 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
vi /etc/default/saslauthd
#
# Settings for saslauthd daemon
# Please read /usr/share/doc/sasl2-bin/README.Debian fo
#
vi /etc/pam.d/smtp
vi /etc/postfix/sasl/smtpd.conf
10 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
pwcheck_method: saslauthd
mech_list: plain login
allow_plaintext: true
auxprop_plugin: mysql
sql_hostnames: 127.0.0.1
sql_user: mail_admin
sql_passwd: mail_admin_password
sql_database: mail
sql_select: select password from users where email = '%
N ext add the postfix us er to the sasl group (this makes s ure that P os tfix has the permis s ion to
ac c es s s as lauthd):
/etc/init.d/postfix restart
/etc/init.d/saslauthd restart
N ow we have to tell C ourier that it s hould authentic ate agains t our M ySQ L databas e. Firs t, edit
/etc/courier/authdaemonrc and c hange the value of authmodulelist s o that it reads :
vi /etc/courier/authdaemonrc
[...]
authmodulelist="authmysql"
[...]
T hen make a bac kup of /etc/courier/authmysqlrc and empty the old file:
11 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
cp /etc/courier/authmysqlrc /etc/courier/authmysqlrc_orig
cat /dev/null > /etc/courier/authmysqlrc
T hen open /etc/courier/authmysqlrc and put the following lines into it:
vi /etc/courier/authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME mail_admin
MYSQL_PASSWORD mail_admin_password
MYSQL_PORT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD password
#MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1
#MYSQL_NAME_FIELD
MYSQL_QUOTA_FIELD quota
T hen res tart C ourier:
/etc/init.d/courier-authdaemon restart
/etc/init.d/courier-imap restart
/etc/init.d/courier-imap-ssl restart
/etc/init.d/courier-pop restart
/etc/init.d/courier-pop-ssl restart
By running
you c an s ee if your P O P 3 s erver is working c orrec tly. I t s hould give bac k +OK Hello there. (T ype quit
to get bac k to the L inux s hell.)
N ow we s hould open /etc/aliases. M ake s ure that postmaster points to root and root to your own
us ername or your email addres s , e.g. like this :
12 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
vi /etc/aliases
[...]
postmaster: root
root: postmaster@yourdomain.tld
[...]
[...]
postmaster: root
root: administrator
[...]
newaliases
/etc/init.d/postfix restart
8 .0 4 L T S) 8 .0 4 L T S) - P age 3
13 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
V irtual U s ers A nd D omains With P os tfix, C ourier, M ySQ L A nd SquirrelM ail (M andriva 2 0 0 8 .1 )
V irtual U s ers A nd D omains With P os tfix, C ourier A nd M ySQ L (C entO S 5 .1 )
V irtual U s ers A nd D omains With P os tfix, C ourier A nd M ySQ L (U buntu 7 .1 0 )
V irtual U s ers A nd D omains With P os tfix, C ourier A nd M ySQ L (Fedora 8 )
Pleas e do not us e the comment function to as k for help! I f you need help, pleas e us e our forum.
Comments will be publis hed after adminis trator approval.
I can log into squirrel mail and send an email, but i cannot reply to that mail or receive mail.
Hello,
Thank you for this great tutoriaL.My mail server is almost running well.
The solution is :
14 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
Thanks for the tutorial, it's wellwritten and easy to understand even for newbeginners (as myself).
I've only encountered one problem. Say that the mail-account password is "password".
Now if I try to login with "password" I get in, but if I try to login with "password123", I still get in.
It doesn't matter what I type as long as it starts with "password".
Fixed it, and will post it here incase anyone else wants to know:
Seems like it's MySQL's ENCRYPT that makes the password so "flexible".
I changed to MD5 and it now works like a charm :)
IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com
15 of 16 11/30/09 12:04
Virtual Users And Domains With Postfix, Courier, ... http://www.howtoforge.com/virtual-users-domains-...
16 of 16 11/30/09 12:04