/[gentoo]/xml/htdocs/doc/en/virt-mail-howto.xml
Gentoo

Diff of /xml/htdocs/doc/en/virt-mail-howto.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.51 Revision 1.61
1<?xml version='1.0' encoding='UTF-8'?> 1<?xml version='1.0' encoding='UTF-8'?>
2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/virt-mail-howto.xml,v 1.51 2006/06/18 22:09:40 nightmorph Exp $ -->
3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/virt-mail-howto.xml,v 1.61 2010/10/14 06:11:38 nightmorph Exp $ -->
4 4
5<guide link="/doc/en/virt-mail-howto.xml"> 5<guide>
6<title>Virtual Mailhosting System with Postfix Guide</title> 6<title>Virtual Mailhosting System with Postfix Guide</title>
7 7
8<author title="Author"> 8<author title="Author">
9 <mail link="antifa@gentoo.org">Ken Nowack</mail> 9 <mail link="antifa@gentoo.org">Ken Nowack</mail>
10</author> 10</author>
15 <mail link="klasikahl@gentoo.org">Zack Gilburd</mail> 15 <mail link="klasikahl@gentoo.org">Zack Gilburd</mail>
16</author> 16</author>
17<author title="Editor"> 17<author title="Editor">
18 <mail link="seather@scygro.za.net">Scygro</mail> 18 <mail link="seather@scygro.za.net">Scygro</mail>
19</author> 19</author>
20<author title="Editor">
21 <mail link="swift@gentoo.org">Sven Vermeulen</mail>
22</author>
20 23
21<abstract> 24<abstract>
22This document details how to create a virtual mailhosting system based upon 25This document details how to create a virtual mailhosting system based upon
23postfix, mysql, courier-imap, and cyrus-sasl. 26postfix, mysql, courier-imap, and cyrus-sasl.
24</abstract> 27</abstract>
25 28
26<version>1.0.28</version> 29<version>2</version>
27<date>2006-06-18</date> 30<date>2010-10-13</date>
28
29<!--
30Contents
31
32I. Introduction
33II. Postfix Basics
34III. Courier-imap
35IV. Cyrus-sasl
36V. SSL Certificates for Postfix and Apache
37VI. Adding SSL and SASL support to Postfix
38VII. MySQL
39VIII. Apache and phpMyAdmin
40IX. The vmail user
41X. Configuring MySQL Authentication and vhosts
42XI. Squirrelmail
43XII. Mailman
44XIII. Content Filtering and Anti-Virus
45XIV. Wrap Up
46XV. Troubleshooting
47-->
48 31
49<chapter> 32<chapter>
50<title>Introduction</title> 33<title>Introduction</title>
51<section> 34<section>
52<body> 35<body>
85needs. Consider investigating <uri>http://www.qmail.org/</uri> and 68needs. Consider investigating <uri>http://www.qmail.org/</uri> and
86<uri>http://www.exim.org/</uri> to explore your options. 69<uri>http://www.exim.org/</uri> to explore your options.
87</p> 70</p>
88 71
89<p> 72<p>
90The following packages are used in this setup: apache, courier-imap, courier-authlib 73The following packages are used in this setup: apache, courier-imap,
91postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and 74courier-authlib postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql,
92mailman. 75php, and mailman.
93</p> 76</p>
94 77
95<p> 78<p>
96Make sure to turn on the following USE variables in <path>/etc/make.conf</path> 79Make sure to turn on the following USE variables in <path>/etc/make.conf</path>
97before compiling the packages: <c>USE="mysql imap libwww maildir 80before compiling the packages: <c>USE="mysql imap libwww maildir
98sasl ssl"</c>. Otherwise you will most likely have to recompile things to 81sasl ssl"</c>. Otherwise you will most likely have to recompile things to
99get the support you need for all the protocols. Further, it's a good idea to 82get the support you need for all the protocols. Further, it's a good idea to
100turn off any other mail and network variables, like ipv6. 83turn off any other mail and network variables, like ipv6.
101</p> 84</p>
102
103<impo>
104This howto was written for postfix-2.0.x. If you are using postfix &lt; 2 some
105of the variables in this document will be different. It is recommended that you
106upgrade. Some other packages included in this howto are version sensitive as
107well. You are advised to read the documentation included with packages if you
108run into issues with this.
109</impo>
110
111<impo>
112This document uses apache-1.3.x. Apache-2 has been marked stable in portage.
113However there are still a number of issues with php integration. Until php
114support in apache-2.0.x is marked stable, this guide will continue to use the
1151.3.x version.
116</impo>
117 85
118<impo> 86<impo>
119You need a domain name to run a public mail server, or at least an MX record 87You need a domain name to run a public mail server, or at least an MX record
120for a domain. Ideally you would have control of at least two domains to take 88for a domain. Ideally you would have control of at least two domains to take
121advantage of your new virtual domain functionality. 89advantage of your new virtual domain functionality.
151# <i>emerge postfix</i> 119# <i>emerge postfix</i>
152</pre> 120</pre>
153 121
154<warn> 122<warn>
155Verify that you have not installed any other MTA, such as ssmtp, exim, or 123Verify that you have not installed any other MTA, such as ssmtp, exim, or
156qmail, or you will surely have BIG problems. 124netqmail, or you will surely have BIG problems.
157</warn> 125</warn>
158 126
159<p> 127<p>
160After postfix is installed, it's time to configure it. Change the following 128After postfix is installed, it's time to configure it. Change the following
161options in <path>/etc/postfix/main.cf</path>: 129options in <path>/etc/postfix/main.cf</path>. Remember to replace
130<c>$variables</c> with your own names.
162</p> 131</p>
163 132
164<pre caption="/etc/postfix/main.cf"> 133<pre caption="/etc/postfix/main.cf">
165myhostname = $host.domain.name 134myhostname = $host.domain.name
166mydomain = $domain.name 135mydomain = $domain.name
193 162
194<pre caption="Starting postfix for the first time"> 163<pre caption="Starting postfix for the first time">
195# <i>/usr/bin/newaliases</i> 164# <i>/usr/bin/newaliases</i>
196<comment>(This will install the new aliases. You only need to do this 165<comment>(This will install the new aliases. You only need to do this
197when you update or install aliases.)</comment> 166when you update or install aliases.)</comment>
198 167
199# <i>/etc/init.d/postfix start</i> 168# <i>/etc/init.d/postfix start</i>
200</pre> 169</pre>
201 170
202<p> 171<p>
203Now that postfix is running, fire up your favorite console mail client and send 172Now that postfix is running, fire up your favorite console mail client and send
245# <i>/etc/init.d/courier-pop3d-ssl start</i> 214# <i>/etc/init.d/courier-pop3d-ssl start</i>
246</pre> 215</pre>
247 216
248<p> 217<p>
249Start up your favorite mail client and verify that all connections you've 218Start up your favorite mail client and verify that all connections you've
250started work for receiving and sending mail. Now that the basics work, we're 219started work for receiving and sending mail. Of course, you won't be able to log
251going to do a whole bunch of stuff at once to get the rest of the system 220on to any of the services because authentication hasn't been configured yet, but
252running. Again, please verify that what we've installed already works before 221it is wise to check if the connections themselves work or not.
253progressing. 222</p>
223
224<p>
225Now that the basics work, we're going to do a whole bunch of stuff at once to
226get the rest of the system running. Again, please verify that what we've
227installed already works before progressing.
254</p> 228</p>
255 229
256</body> 230</body>
257</section> 231</section>
258</chapter> 232</chapter>
262<section> 236<section>
263<body> 237<body>
264 238
265<p> 239<p>
266Next we're going to install cyrus-sasl. Sasl is going to play the role of 240Next we're going to install cyrus-sasl. Sasl is going to play the role of
267actually passing your auth variables to courier-auth, which will in turn pass that 241actually passing your auth variables to courier-auth, which will in turn pass
268information to mysql for authentication of smtp users. For this howto, we'll 242that information to mysql for authentication of smtp users. For this howto,
269not even try to verify that sasl is working until mysql is set up and contains 243we'll not even try to verify that sasl is working until mysql is set up and
270a test user. Which is fine since we'll be authenticating against mysql in the 244contains a test user. Which is fine since we'll be authenticating against
271end anyway. 245mysql in the end anyway.
272</p> 246</p>
273 247
274<pre caption="Configuring and installing the cyrus-sasl ebuild"> 248<pre caption="Configuring and installing the cyrus-sasl ebuild">
275# <i>emerge cyrus-sasl</i> 249# <i>emerge cyrus-sasl</i>
276</pre> 250</pre>
315emailAddress_default. 289emailAddress_default.
316 290
317<comment>(If the variables are not already present, just add them in a sensible place.)</comment> 291<comment>(If the variables are not already present, just add them in a sensible place.)</comment>
318 292
319# <i>cd misc</i> 293# <i>cd misc</i>
320# <i>nano -w CA.pl</i> 294# <i>./CA.pl -newreq-nodes</i>
321<comment>(We need to add -nodes to the # create a certificate and
322#create a certificate request code in order to let our new ssl
323certs be loaded without a password. Otherwise when you
324reboot your ssl certs will not be available.)</comment>
325
326# create a certificate
327system ("$REQ -new -nodes -x509 -keyout newreq.pem -out newreq.pem $DAYS");
328
329# create a certificate request
330system ("$REQ -new -nodes -keyout newreq.pem -out newreq.pem $DAYS");
331
332# <i>./CA.pl -newca</i> 295# <i>./CA.pl -newca</i>
333# <i>./CA.pl -newreq</i>
334# <i>./CA.pl -sign</i> 296# <i>./CA.pl -sign</i>
335# <i>cp newcert.pem /etc/postfix</i> 297# <i>cp newcert.pem /etc/postfix</i>
336# <i>cp newreq.pem /etc/postfix</i> 298# <i>cp newkey.pem /etc/postfix</i>
337# <i>cp demoCA/cacert.pem /etc/postfix</i> 299# <i>cp demoCA/cacert.pem /etc/postfix</i>
338<comment>(Now we do the same thing for apache.)</comment> 300<comment>(Now we do the same thing for apache.)</comment>
339 301
340# <i>openssl req -new > new.cert.csr</i> 302# <i>openssl req -new > new.cert.csr</i>
341# <i>openssl rsa -in privkey.pem -out new.cert.key</i> 303# <i>openssl rsa -in privkey.pem -out new.cert.key</i>
374smtpd_sasl_local_domain appends a domain name to clients using 336smtpd_sasl_local_domain appends a domain name to clients using
375smtp-auth. Make sure it's blank or your user names will get 337smtp-auth. Make sure it's blank or your user names will get
376mangled by postfix and be unable to auth.)</comment> 338mangled by postfix and be unable to auth.)</comment>
377 339
378smtpd_recipient_restrictions = 340smtpd_recipient_restrictions =
379 permit_sasl_authenticated, 341 permit_sasl_authenticated,
380 permit_mynetworks, 342 permit_mynetworks,
381 reject_unauth_destination 343 reject_unauth_destination
382
383 344
384<comment>(The next two options enable outgoing encryption.)</comment> 345<comment>(The next two options enable outgoing encryption.)</comment>
385smtp_use_tls = yes 346smtp_use_tls = yes
386smtp_tls_note_starttls_offer = yes 347smtp_tls_note_starttls_offer = yes
387smtpd_use_tls = yes 348smtpd_use_tls = yes
388#smtpd_tls_auth_only = yes 349#smtpd_tls_auth_only = yes
389smtpd_tls_key_file = /etc/postfix/newreq.pem 350smtpd_tls_key_file = /etc/postfix/newkey.pem
390smtpd_tls_cert_file = /etc/postfix/newcert.pem 351smtpd_tls_cert_file = /etc/postfix/newcert.pem
391smtpd_tls_CAfile = /etc/postfix/cacert.pem 352smtpd_tls_CAfile = /etc/postfix/cacert.pem
392smtpd_tls_loglevel = 3 353smtpd_tls_loglevel = 3
393smtpd_tls_received_header = yes 354smtpd_tls_received_header = yes
394smtpd_tls_session_cache_timeout = 3600s 355smtpd_tls_session_cache_timeout = 3600s
400# <i>postfix reload</i> 361# <i>postfix reload</i>
401</pre> 362</pre>
402 363
403<p> 364<p>
404Now we're going to verify that the config's we added were picked up by postfix. 365Now we're going to verify that the config's we added were picked up by postfix.
366For this we are going to use <c>telnet</c> (provided by for instance
367<c>net-misc/netkit-telnetd</c>) although you can also use <c>nc</c> (provided by
368<c>net-analyzer/netcat</c>):
405</p> 369</p>
406 370
407<pre caption="Verifying sasl and tls support"> 371<pre caption="Verifying sasl and tls support">
408# <i>telnet localhost 25</i> 372# <i>telnet localhost 25</i>
409 373
437</body> 401</body>
438</section> 402</section>
439</chapter> 403</chapter>
440 404
441<chapter> 405<chapter>
406<title>The vmail user</title>
407<section>
408<body>
409
410<p>
411Before we set up our virtual mailhosting environment, we create a functional
412user under which the virtual mailboxes will be hosted. For clarity's sake we
413will call this <e>vmail</e>:
414</p>
415
416<pre caption="Adding the vmail user">
417# <i>useradd -d /home/vmail -s /bin/false -m vmail</i>
418</pre>
419
420<p>
421So now you've set up the vmail account. You can create multiple accounts if you
422want (to keep some structure in your set of virtual mail accounts). The user id,
423group id and home dirs are referenced in the MySQL tables.
424</p>
425
426<p>
427Next to the user account we also need to create the location where the mailboxes
428will reside:
429</p>
430
431<pre caption="Creating mailboxes">
432# <i>mkdir -p /home/vmail/virt-domain.com/foo</i>
433# <i>chown -R vmail:vmail /home/vmail/virt-domain.com</i>
434# <i>maildirmake /home/vmail/virt-domain.com/foo/.maildir</i>
435</pre>
436
437</body>
438</section>
439</chapter>
440
441<chapter>
442<title>MySQL</title> 442<title>MySQL</title>
443<section> 443<section>
444<body> 444<body>
445 445
446<p> 446<p>
452<pre caption="Installing and configuring MySQL"> 452<pre caption="Installing and configuring MySQL">
453# <i>emerge mysql</i> 453# <i>emerge mysql</i>
454 454
455# <i>/usr/bin/mysql_install_db</i> 455# <i>/usr/bin/mysql_install_db</i>
456<comment>(After this command runs follow the onscreen directions 456<comment>(After this command runs follow the onscreen directions
457for adding a root password with mysql, 457for adding a root password with mysql, otherwise your db will
458not mysqladmin, otherwise your db will be wide open.)</comment> 458be wide open.)</comment>
459 459
460# <i>/etc/init.d/mysql start</i> 460# <i>/etc/init.d/mysql start</i>
461# <i>mysqladmin -u root -p create mailsql</i> 461# <i>mysqladmin -u root -p create mailsql</i>
462# <i>mysql -u root -p mailsql &lt; genericmailsql.sql</i> 462# <i>mysql -u root -p mailsql &lt; genericmailsql.sql</i>
463
464# <i>mysql -u root -p mysql</i> 463# <i>mysql -u root -p mysql</i>
465mysql> <i>GRANT SELECT,INSERT,UPDATE,DELETE</i> 464mysql> <i>GRANT SELECT,INSERT,UPDATE,DELETE</i>
466 -> <i>ON mailsql.*</i> 465 -> <i>ON mailsql.*</i>
467 -> <i>TO mailsql@localhost</i> 466 -> <i>TO mailsql@localhost</i>
468 -> <i>IDENTIFIED BY '$password';</i> 467 -> <i>IDENTIFIED BY '$password';</i>
469Query OK, 0 rows affected (0.02 sec) 468Query OK, 0 rows affected (0.02 sec)
470 469
471mysql> <i>FLUSH PRIVILEGES;</i> 470mysql> <i>FLUSH PRIVILEGES;</i>
472Query OK, 0 rows affected (0.00 sec) 471Query OK, 0 rows affected (0.00 sec)
473 472
492 <li>users - all user account information</li> 491 <li>users - all user account information</li>
493 <li>virtual - virtual domain email alias maps</li> 492 <li>virtual - virtual domain email alias maps</li>
494</ul> 493</ul>
495 494
496<pre caption="alias table sample"> 495<pre caption="alias table sample">
497id alias destination 496id alias destination
4981 root foo@bar.com 4971 root foo@bar.com
4992 postmaster foo@bar.com 4982 postmaster foo@bar.com
500</pre> 499</pre>
501 500
502<pre caption="user table sample"> 501<pre caption="user table sample">
503<comment>(Line wrapped for clarity.)</comment> 502<comment>(Line wrapped for clarity.)</comment>
504id email clear name uid gid homedir \ 503id email clear name uid gid homedir \
505 maildir quota postfix 504 maildir quota postfix
50610 foo@virt-bar.org $password realname virtid virtid /home/vmail \ 50510 foo@virt-domain.com $password realname virtid virtid /home/vmail \
507 /home/vmail/virt-bar.org/foo/.maildir/ y 506 /home/vmail/virt-domain.com/foo/.maildir/ y
50813 foo@bar.com $password realname localid localid /home/foo \ 50713 foo@bar.com $password realname localid localid /home/foo \
509 /home/foo/.maildir/ y 508 /home/foo/.maildir/ y
510</pre> 509</pre>
511 510
512<p> 511<p>
513The values of the <c>virtid</c> uid and gid should be those of the <c>vmail</c> 512The values of the <c>virtid</c> uid and gid should be those of the <c>vmail</c>
514user and group. 513user and group.
515</p> 514</p>
516 515
517<pre caption="transport table sample"> 516<pre caption="transport table sample">
518id domain destination 517id domain destination
5191 bar.com local: 5181 bar.com local:
5202 virt-bar.org virtual: 5192 virt-domain.com virtual:
521</pre> 520</pre>
522 521
523<pre caption="virtual table sample"> 522<pre caption="virtual table sample">
524id email destination 523id email destination
5253 root@virt-bar.org other@email.address 5243 root@virt-domain.com other@email.address
526</pre> 525</pre>
527 526
528</body> 527</body>
529</section> 528</section>
530</chapter> 529</chapter>
538Next we'll set up apache and add an interface to interact with the database 537Next we'll set up apache and add an interface to interact with the database
539more easily. 538more easily.
540</p> 539</p>
541 540
542<pre caption="Setting up apache and phpmyadmin"> 541<pre caption="Setting up apache and phpmyadmin">
543# <i>emerge apache mod_php phpmyadmin</i> 542# <i>emerge apache phpmyadmin</i>
544</pre> 543</pre>
545 544
546<p> 545<p>
547There are plenty of guides out there about how to set up apache with php. Like 546There are plenty of guides out there about how to set up apache with php,
548this one: <uri>http://www.linuxguruz.org/z.php?id=31</uri>. There are also 547including guides provided by the <uri link="/proj/en/php/">Gentoo PHP
548Project</uri>. There are also numerous posts on
549numerous posts on <uri>http://forums.gentoo.org</uri> detailing how to solve 549<uri>http://forums.gentoo.org</uri> detailing how to solve problems with the
550problems with the installation (search for 'apache php'). So, that said, I'm 550installation. So, that said, we're not going to cover it here. Set up the
551not going to cover it here. Set up the apache and php installs, then continue 551apache and php installs, then continue with this howto. Now, a word for the
552with this howto. Now, a word for the wise: .htaccess the directory that you put 552wise: .htaccess the directory that you put phpmyadmin in. If you do not do this,
553phpmyadmin in. If you do not do this, search engine spiders will come along and 553search engine spiders will come along and index the page which in turn will mean
554index the page which in turn will mean that anyone will be able to find your 554that anyone will be able to find your phpmyadmin page via google and in turn be
555phpmyadmin page via google and in turn be able to come change your database 555able to come change your database however they want which is <e>BAD!</e> There
556however they want which is <e>BAD!</e> There are many howtos on this 556are many howtos on this including:
557including: <uri>http://www.csoft.net/docs/micro/htaccess.html.en</uri>. 557<uri>http://www.csoft.net/docs/micro/htaccess.html.en</uri>.
558</p> 558</p>
559 559
560<p> 560<p>
561Now we're going to install the Apache certificates we made previously. The 561Now we're going to install the Apache certificates we made previously. The
562Apache-SSL directives that you need to use the resulting cert are: 562Apache-SSL directives that you need to use the resulting cert are:
566 <li>SSLCertificateFile /path/to/certs/new.cert.cert</li> 566 <li>SSLCertificateFile /path/to/certs/new.cert.cert</li>
567 <li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li> 567 <li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li>
568</ul> 568</ul>
569 569
570<pre caption="Install Apache SSL certificates"> 570<pre caption="Install Apache SSL certificates">
571# <i>cp /etc/ssl/misc/new.cert.cert /etc/apache/conf/ssl/</i> 571# <i>cp /etc/ssl/misc/new.cert.cert /etc/apache2/ssl/</i>
572# <i>cp /etc/ssl/misc/new.cert.key /etc/apache/conf/ssl/</i> 572# <i>cp /etc/ssl/misc/new.cert.key /etc/apache2/ssl/</i>
573# <i>nano -w /etc/apache/conf/vhosts/ssl.default-vhost.conf</i> 573# <i>cd /etc/apache2/vhosts.d</i>
574<comment>(Check if you have an ssl-vhost template already.
575 Copy that one instead of the default_vhost if that is the case)</comment>
576# <i>cp 00_default_vhost.conf ssl-vhost.conf</i>
577# <i>nano -w ssl-vhost.conf</i>
574 578
575<comment>(Change the following parameters)</comment> 579<comment>(Change the following parameters)</comment>
580NameVirtualHost host.domain.name:443
576 581
582&lt;VirtualHost host.domain.name:443&gt;
577ServerName host.domain.name 583 ServerName host.domain.name
578ServerAdmin your@email.address 584 ServerAdmin your@email.address
585
586 DocumentRoot "/var/www/localhost/htdocs/phpmyadmin";
587 &lt;Directory "/var/www/localhost/htdocs/phpmyadmin"&gt;
588 ...
589 &lt;/Directory&gt;
590
579SSLCertificateFile /etc/apache/conf/ssl/new.cert.cert 591 SSLCertificateFile /etc/apache2/ssl/new.cert.cert
580SSLCertificateKeyFile /etc/apache/conf/ssl/new.cert.key 592 SSLCertificateKeyFile /etc/apache2/ssl/new.cert.key
593 SSLEngine on
594 ...
595&lt;/VirtualHost&gt;
581 596
597# <i>nano -w /etc/conf.d/apache2</i>
598<comment>(Add -D SSL -D PHP5 to the APACHE2_OPTS)</comment>
599
582# <i>/etc/init.d/apache restart</i> 600# <i>/etc/init.d/apache2 restart</i>
583</pre> 601</pre>
584
585<note>
586If you have an existing apache install, you'll likely have to perform a full
587server reboot to install your new certificates. Check your logs to verify
588apache restarted successfully.
589</note>
590 602
591<p> 603<p>
592Next, configure phpMyAdmin. 604Next, configure phpMyAdmin.
593</p> 605</p>
594 606
595<pre caption="Configuring phpMyAdmin"> 607<pre caption="Configuring phpMyAdmin">
596# <i>nano -w /var/www/localhost/htdocs/phpmyadmin/config.inc.php</i> 608# <i>cd /var/www/localhost/htdocs/phpmyadmin</i>
609# <i>cp config.sample.inc.php config.inc.php</i>
610# <i>nano -w config.inc.php</i>
597<comment>(Change the following parameters.)</comment> 611<comment>(Change the following parameters.)</comment>
612$cfg['blowfish_secret'] = 'someverysecretpassphraze';
598 613
599$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname 614$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname
600$cfg['Servers'][$i]['controluser'] = 'mailsql'; // MySQL control user settings 615$cfg['Servers'][$i]['controluser'] = 'mailsql'; // MySQL control user settings
601 // (this user must have read-only 616 // (this user must have read-only
602$cfg['Servers'][$i]['controlpass'] = '$password'; // access to the "mysql/user" 617$cfg['Servers'][$i]['controlpass'] = '$password'; // access to the "mysql/user"
609Now enter the phpmyadmin page and browse the tables. You'll want to add in your 624Now enter the phpmyadmin page and browse the tables. You'll want to add in your
610local aliases, edit your user table to add a test user, and change your 625local aliases, edit your user table to add a test user, and change your
611transport table to add information about your domains. The default values 626transport table to add information about your domains. The default values
612supplied with the dumpfile should be a sufficient guide to what values need to 627supplied with the dumpfile should be a sufficient guide to what values need to
613go where. Make sure that if you put information in the database that it is 628go where. Make sure that if you put information in the database that it is
614accurate. For instance, make sure the local users home dir exists and that the 629accurate. For instance, make sure the local user's home dir exists and that the
615correct uid/gid values are in place. The maildirs should be created 630correct uid/gid values are in place. The maildirs should be created
616automatically by postfix when the user receives their first email. So, in 631automatically by postfix when the user receives their first email. So, in
617general, it's a good idea to send a "Welcome" mail to a new user 632general, it's a good idea to send a "Welcome" mail to a new user after you
618after you setup their account to make sure the .maildir gets created. 633setup their account to make sure the .maildir gets created.
619</p>
620
621</body>
622</section>
623</chapter>
624
625<chapter>
626<title>The vmail user</title>
627<section>
628<body>
629
630<p>
631At this point you may be wondering what user and directory to use for virtual
632mail users, and rightly so. Let's set that up.
633</p>
634
635<pre caption="Adding the vmail user">
636# <i>adduser -d /home/vmail -s /bin/false vmail</i>
637# <i>uid=`cat /etc/passwd | grep vmail | cut -f 3 -d :`</i>
638# <i>groupadd -g $uid vmail</i>
639# <i>mkdir /home/vmail</i>
640# <i>chown vmail: /home/vmail</i>
641</pre>
642
643<p>
644So now when you're setting up vmail accounts, use the vmail uid, gid, and
645homedir. When you're setting up local accounts, use that users uid, gid, and
646homedir. We've been meaning to create a php admin page for this setup but
647haven't gotten around to it yet, as phpmyadmin generally works fine for us.
648</p> 634</p>
649 635
650</body> 636</body>
651</section> 637</section>
652</chapter> 638</chapter>
685# <i>/etc/init.d/courier-authlib restart</i> 671# <i>/etc/init.d/courier-authlib restart</i>
686# <i>/etc/init.d/saslauthd restart</i> 672# <i>/etc/init.d/saslauthd restart</i>
687</pre> 673</pre>
688 674
689<p> 675<p>
690We're almost there I promise! Next, set up the rest of the necessary config's 676We're almost there, I promise! Next, set up the rest of the necessary configs
691for postfix to interract with the database for all it's other transport needs. 677for postfix to interract with the database for all its other transport needs.
678Remember to replace each value with the name of your own user, user id,
679password, alias, email address, and so on.
692</p> 680</p>
693 681
694<pre caption="/etc/postfix/mysql-aliases.cf"> 682<pre caption="/etc/postfix/mysql-aliases.cf">
695# <i>nano -w /etc/postfix/mysql-aliases.cf</i> 683# <i>nano -w /etc/postfix/mysql-aliases.cf</i>
696# mysql-aliases.cf 684# mysql-aliases.cf
697 685
698user = mailsql 686user = mailsql
699password = $password 687password = $password
700dbname = mailsql 688dbname = mailsql
701table = alias 689table = alias
702select_field = destination 690select_field = destination
703where_field = alias 691where_field = alias
704hosts = unix:/var/run/mysqld/mysqld.sock 692hosts = unix:/var/run/mysqld/mysqld.sock
705</pre> 693</pre>
706 694
707<pre caption="/etc/postfix/mysql-relocated.cf"> 695<pre caption="/etc/postfix/mysql-relocated.cf">
708# <i>nano -w /etc/postfix/mysql-relocated.cf</i> 696# <i>nano -w /etc/postfix/mysql-relocated.cf</i>
709# mysql-relocated.cf 697# mysql-relocated.cf
710 698
711user = mailsql 699user = mailsql
712password = $password 700password = $password
713dbname = mailsql 701dbname = mailsql
714table = relocated 702table = relocated
715select_field = destination 703select_field = destination
716where_field = email 704where_field = email
717hosts = unix:/var/run/mysqld/mysqld.sock 705hosts = unix:/var/run/mysqld/mysqld.sock
718</pre> 706</pre>
719 707
720<pre caption="/etc/postfix/mysql-transport.cf (optional)"> 708<pre caption="/etc/postfix/mysql-transport.cf (optional)">
721# <i>nano -w /etc/postfix/mysql-transport.cf</i> 709# <i>nano -w /etc/postfix/mysql-transport.cf</i>
722# mysql-transport.cf 710# mysql-transport.cf
723 711
724user = mailsql 712user = mailsql
725password = $password 713password = $password
726dbname = mailsql 714dbname = mailsql
727table = transport 715table = transport
728select_field = destination 716select_field = destination
729where_field = domain 717where_field = domain
730hosts = unix:/var/run/mysqld/mysqld.sock 718hosts = unix:/var/run/mysqld/mysqld.sock
731</pre> 719</pre>
732 720
733<pre caption="/etc/postfix/mysql-virtual-gid.cf (optional)"> 721<pre caption="/etc/postfix/mysql-virtual-gid.cf (optional)">
734# <i>nano -w /etc/postfix/mysql-virtual-gid.cf</i> 722# <i>nano -w /etc/postfix/mysql-virtual-gid.cf</i>
735#myql-virtual-gid.cf 723# mysql-virtual-gid.cf
736 724
737user = mailsql 725user = mailsql
738password = $password 726password = $password
739dbname = mailsql 727dbname = mailsql
740table = users 728table = users
741select_field = gid 729select_field = gid
742where_field = email 730where_field = email
743additional_conditions = and postfix = 'y' 731additional_conditions = and postfix = 'y'
744hosts = unix:/var/run/mysqld/mysqld.sock 732hosts = unix:/var/run/mysqld/mysqld.sock
745</pre> 733</pre>
746 734
747<pre caption="/etc/postfix/mysql-virtual-maps.cf"> 735<pre caption="/etc/postfix/mysql-virtual-maps.cf">
748# <i>nano -w /etc/postfix/mysql-virtual-maps.cf</i> 736# <i>nano -w /etc/postfix/mysql-virtual-maps.cf</i>
749#myql-virtual-maps.cf 737# mysql-virtual-maps.cf
750 738
751user = mailsql 739user = mailsql
752password = $password 740password = $password
753dbname = mailsql 741dbname = mailsql
754table = users 742table = users
755select_field = maildir 743select_field = maildir
756where_field = email 744where_field = email
757additional_conditions = and postfix = 'y' 745additional_conditions = and postfix = 'y'
758hosts = unix:/var/run/mysqld/mysqld.sock 746hosts = unix:/var/run/mysqld/mysqld.sock
759</pre> 747</pre>
760 748
761<pre caption="/etc/postfix/mysql-virtual-uid.cf (optional)"> 749<pre caption="/etc/postfix/mysql-virtual-uid.cf (optional)">
765user = mailsql 753user = mailsql
766password = $password 754password = $password
767dbname = mailsql 755dbname = mailsql
768table = users 756table = users
769select_field = uid 757select_field = uid
770where_field = email 758where_field = email
771additional_conditions = and postfix = 'y' 759additional_conditions = and postfix = 'y'
772hosts = unix:/var/run/mysqld/mysqld.sock 760hosts = unix:/var/run/mysqld/mysqld.sock
773</pre> 761</pre>
774 762
775<pre caption="/etc/postfix/mysql-virtual.cf"> 763<pre caption="/etc/postfix/mysql-virtual.cf">
776# <i>nano -w /etc/postfix/mysql-virtual.cf</i> 764# <i>nano -w /etc/postfix/mysql-virtual.cf</i>
777# mysql-virtual.cf 765# mysql-virtual.cf
778 766
779user = mailsql 767user = mailsql
780password = $password 768password = $password
781dbname = mailsql 769dbname = mailsql
782table = virtual 770table = virtual
783select_field = destination 771select_field = destination
784where_field = email 772where_field = email
785hosts = unix:/var/run/mysqld/mysqld.sock 773hosts = unix:/var/run/mysqld/mysqld.sock
786</pre> 774</pre>
787 775
788<p> 776<p>
789Lastly, edit <path>/etc/postfix/main.cf</path> one more time. 777Lastly, edit <path>/etc/postfix/main.cf</path> one more time.
790</p> 778</p>
791 779
792<pre caption="/etc/postfix/main.cf"> 780<pre caption="/etc/postfix/main.cf">
793# <i>nano -w /etc/postfix/main.cf</i> 781# <i>nano -w /etc/postfix/main.cf</i>
782<comment>(Ensure that there are no other alias_maps definitions)</comment>
794alias_maps = mysql:/etc/postfix/mysql-aliases.cf 783alias_maps = mysql:/etc/postfix/mysql-aliases.cf
795relocated_maps = mysql:/etc/postfix/mysql-relocated.cf 784relocated_maps = mysql:/etc/postfix/mysql-relocated.cf
796 785
797local_transport = local 786local_transport = local
798local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname 787local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname
799 788
800virtual_transport = virtual 789virtual_transport = virtual
801virtual_mailbox_domains = 790<comment>(The domains listed by the mydestination should not be listed in
802 virt-bar.com, 791 the virtual_mailbox_domains parameter)</comment>
803 $other-virtual-domain.com 792virtual_mailbox_domains = virt-domain.com, $other-virtual-domain.com
804 793
805virtual_minimum_uid = 1000 794virtual_minimum_uid = 1000
795<comment>(Substitute $vmail-gid with the GID of the vmail group)</comment>
806virtual_gid_maps = static:$vmail-gid 796virtual_gid_maps = static:$vmail-gid
807virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-maps.cf 797virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-maps.cf
808virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf 798virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf
799<comment>(Substitute $vmail-uid with the UID of the vmail user)</comment>
809virtual_uid_maps = static:$vmail-uid 800virtual_uid_maps = static:$vmail-uid
810virtual_mailbox_base = / 801virtual_mailbox_base = /
811#virtual_mailbox_limit = 802#virtual_mailbox_limit =
812</pre> 803</pre>
813 804
883to require a bit of hacking. I really recommend reading all of the mailman 874to require a bit of hacking. I really recommend reading all of the mailman
884documentation, including README.POSTFIX.gz, to understand what's being done 875documentation, including README.POSTFIX.gz, to understand what's being done
885here. 876here.
886</p> 877</p>
887 878
888<p>
889One further note, current versions of mailman install to /usr/local/mailman. If
890you're like me and wish to change the default install location, it can be
891overridden in the ebuild file by changing the INSTALLDIR variable.
892</p>
893
894<pre caption="Install mailman"> 879<pre caption="Install mailman">
895# <i>emerge mailman</i> 880# <i>emerge mailman</i>
896</pre> 881</pre>
897 882
898<pre caption="Setting defaults: Mailman/Defaults.py"> 883<pre caption="Setting defaults: Mailman/Defaults.py">
899# <i> nano -w /var/mailman/Mailman/Defaults.py</i> 884# <i> nano -w /usr/local/mailman/Mailman/Defaults.py</i>
900<comment>(Change the values below to reflect your primary domain, virtuals will be set next.)</comment> 885<comment>(Change the values below to reflect your primary domain, virtuals will be set next.)</comment>
901DEFAULT_EMAIL_HOST = 'domain.com' 886DEFAULT_EMAIL_HOST = 'domain.com'
902DEFAULT_URL_HOST = 'www.domain.com' 887DEFAULT_URL_HOST = 'www.domain.com'
903</pre> 888</pre>
904 889
905<pre caption="mailman config: mm_cfg.py"> 890<pre caption="mailman config: mm_cfg.py">
906# <i>nano -w /var/mailman/Mailman/mm_cfg.py</i> 891# <i>nano -w /usr/local/mailman/Mailman/mm_cfg.py</i>
907MTA = "Postfix" 892MTA = "Postfix"
908POSTFIX_STYLE_VIRTUAL_DOMAINS = ['virt-domain.com', 'virt.domain2.com'] 893POSTFIX_STYLE_VIRTUAL_DOMAINS = ['virt-domain.com', 'virt.domain2.com']
909add_virtualhost('www.virt.domain.com', 'virt.domain.com') 894add_virtualhost('www.virt.domain.com', 'virt.domain.com')
910add_virtualhost('www.virt.domain2.com', 'virt.domain2.com') 895add_virtualhost('www.virt.domain2.com', 'virt.domain2.com')
911<comment>(This is required for your virtual domains for mailman to function.)</comment> 896<comment>(This is required for your virtual domains for mailman to function.)</comment>
912</pre> 897</pre>
913 898
914<pre caption="And last but not least"> 899<pre caption="And last but not least">
915<comment>(Once that's finished, add your first list.)</comment> 900<comment>(Once that's finished, add your first list.)</comment>
916 901
917# <i>su mailman</i> 902# <i>su mailman</i>
918# <i>cd ~</i> 903# <i>cd ~</i>
919# <i>bin/newlist test</i> 904# <i>./bin/newlist --urlhost='www.virt-domain.com' --emailhost='virt-domain.com' test</i>
920Enter the email of the person running the list: <i>your@email.address</i> 905Enter the email of the person running the list: <i>your@email.address</i>
921Initial test password: 906Initial test password:
922Hit enter to continue with test owner notification... 907Hit enter to continue with test owner notification...
923<comment>(Virtual domain lists may be specified with 908<comment>(Virtual domain lists may also be specified with
924list@domain.com style list names.)</comment> 909list@domain.com style list names.)</comment>
925# <i>bin/genaliases</i> 910# <i>./bin/genaliases</i>
926<comment>(Now that your aliases have been generated, 911<comment>(Now that your aliases have been generated,
927verify that they were added successfully.)</comment> 912verify that they were added successfully.)</comment>
928 913
929# <i>nano -w data/aliases</i> 914# <i>nano -w data/aliases</i>
930# STANZA START: test 915# STANZA START: test
931# CREATED: 916# CREATED:
932test: "|/var/mailman/mail/mailman post test" 917test: "|/usr/local/mailman/mail/mailman post test"
933test-admin: "|/var/mailman/mail/mailman admin test" 918test-admin: "|/usr/local/mailman/mail/mailman admin test"
934test-bounces: "|/var/mailman/mail/mailman bounces test" 919test-bounces: "|/usr/local/mailman/mail/mailman bounces test"
935test-confirm: "|/var/mailman/mail/mailman confirm test" 920test-confirm: "|/usr/local/mailman/mail/mailman confirm test"
936test-join: "|/var/mailman/mail/mailman join test" 921test-join: "|/usr/local/mailman/mail/mailman join test"
937test-leave: "|/var/mailman/mail/mailman leave test" 922test-leave: "|/usr/local/mailman/mail/mailman leave test"
938test-owner: "|/var/mailman/mail/mailman owner test" 923test-owner: "|/usr/local/mailman/mail/mailman owner test"
939test-request: "|/var/mailman/mail/mailman request test" 924test-request: "|/usr/local/mailman/mail/mailman request test"
940test-subscribe: "|/var/mailman/mail/mailman subscribe test" 925test-subscribe: "|/usr/local/mailman/mail/mailman subscribe test"
941test-unsubscribe: "|/var/mailman/mail/mailman unsubscribe test" 926test-unsubscribe: "|/usr/local/mailman/mail/mailman unsubscribe test"
942# STANZA END: test 927# STANZA END: test
928
929<comment>(Create the required mailman list)</comment>
930# <i>./bin/newlist mailman</i>
931# <i>./bin/genaliases</i>
932
933<comment>(Return to the root user)</comment>
934# <i>exit</i>
943 935
944# <i>/etc/init.d/mailman start</i> 936# <i>/etc/init.d/mailman start</i>
945# <i>rc-update add mailman default</i> 937# <i>rc-update add mailman default</i>
946<comment>(To start mailman at once and on every reboot.)</comment> 938<comment>(To start mailman at once and on every reboot.)</comment>
947</pre> 939</pre>
951owner_request_special = no 943owner_request_special = no
952recipient_delimiter = + 944recipient_delimiter = +
953<comment>(Read README.POSTFIX.gz for details on this.)</comment> 945<comment>(Read README.POSTFIX.gz for details on this.)</comment>
954 946
955alias_maps = 947alias_maps =
956 hash:/var/mailman/data/aliases, 948 hash:/usr/local/mailman/data/aliases,
957 mysql:/etc/postfix/mysql-aliases.cf 949 mysql:/etc/postfix/mysql-aliases.cf
958 950
959virtual_alias_maps = 951virtual_alias_maps =
960 hash:/var/mailman/data/virtual-mailman, 952 hash:/usr/local/mailman/data/virtual-mailman,
961 mysql:/etc/postfix/mysql-virtual.cf 953 mysql:/etc/postfix/mysql-virtual.cf
962<comment>(This adds mailman alias file support to postfix 954<comment>(This adds mailman alias file support to postfix
963You may of course use the mysql tables for this, 955You may of course use the mysql tables for this,
964but I hate doing that by hand. Also, if you are not 956but I hate doing that by hand. Also, if you are not
965using virtual domains, adding the virtual alias maps 957using virtual domains, adding the virtual alias maps
966to postfix may cause problems, be warned.)</comment> 958to postfix may cause problems, be warned.)</comment>
1086sure it's using the current version. Some of the components will dump their 1078sure it's using the current version. Some of the components will dump their
1087current config's to you, like postfix. 1079current config's to you, like postfix.
1088</p> 1080</p>
1089 1081
1090<pre caption="Some services can dump their current config"> 1082<pre caption="Some services can dump their current config">
1091# <i>apachectl fullstatus</i> (needs lynx installed) 1083# <i>apache2ctl fullstatus</i> (needs lynx installed)
1092# <i>apachectl configtest</i> (checks config sanity) 1084# <i>apache2ctl configtest</i> (checks config sanity)
1093# <i>postconf -n</i> (will tell you exactly what param's postfix is using) 1085# <i>postconf -n</i> (will tell you exactly what param's postfix is using)
1094# <i>/etc/init.d/$service restart</i> 1086# <i>/etc/init.d/$service restart</i>
1095</pre> 1087</pre>
1096 1088
1097</body> 1089</body>
1111 1103
1112<pre caption="Checking the logs"> 1104<pre caption="Checking the logs">
1113# <i>kill -USR1 `ps -C metalog -o pid=`</i>(to turn off metalog buffering) 1105# <i>kill -USR1 `ps -C metalog -o pid=`</i>(to turn off metalog buffering)
1114# <i>nano -w /var/log/mail/current</i> 1106# <i>nano -w /var/log/mail/current</i>
1115# <i>cat /var/log/mysql/mysql.log</i> 1107# <i>cat /var/log/mysql/mysql.log</i>
1116# <i>tail /var/log/apache/error_log</i> 1108# <i>tail /var/log/apache2/error_log</i>
1117</pre> 1109</pre>
1118 1110
1119<p> 1111<p>
1120You may also find the debug_peer parameters in main.cf helpful. Setting these 1112You may also find the debug_peer parameters in main.cf helpful. Setting these
1121will increase log output over just verbose mode. 1113will increase log output over just verbose mode.
1204 <li> 1196 <li>
1205 <uri>http://www.google.com/</uri> - If all else fails, there's always 1197 <uri>http://www.google.com/</uri> - If all else fails, there's always
1206 google, which has never failed me 1198 google, which has never failed me
1207 </li> 1199 </li>
1208 <li> 1200 <li>
1209 I also spend a lot of time on irc.freenode.net #gentoo. Irc is a great 1201 I also spend a lot of time on <uri
1210 place to go for help. 1202 link="irc://irc.gentoo.org/gentoo">#gentoo</uri>. IRC is a great place to go
1203 for help.
1211 </li> 1204 </li>
1212</ul> 1205</ul>
1213 1206
1214</body> 1207</body>
1215</section> 1208</section>

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.61

  ViewVC Help
Powered by ViewVC 1.1.20