/[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.57 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.57 2007/07/23 15:44:42 swift 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>
24<abstract> 24<abstract>
25This document details how to create a virtual mailhosting system based upon 25This document details how to create a virtual mailhosting system based upon
26postfix, mysql, courier-imap, and cyrus-sasl. 26postfix, mysql, courier-imap, and cyrus-sasl.
27</abstract> 27</abstract>
28 28
29<version>1.5</version> 29<version>2</version>
30<date>2007-07-23</date> 30<date>2010-10-13</date>
31 31
32<chapter> 32<chapter>
33<title>Introduction</title> 33<title>Introduction</title>
34<section> 34<section>
35<body> 35<body>
68needs. Consider investigating <uri>http://www.qmail.org/</uri> and 68needs. Consider investigating <uri>http://www.qmail.org/</uri> and
69<uri>http://www.exim.org/</uri> to explore your options. 69<uri>http://www.exim.org/</uri> to explore your options.
70</p> 70</p>
71 71
72<p> 72<p>
73The following packages are used in this setup: apache, courier-imap, courier-authlib 73The following packages are used in this setup: apache, courier-imap,
74postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and 74courier-authlib postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql,
75mailman. 75php, and mailman.
76</p> 76</p>
77 77
78<p> 78<p>
79Make 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>
80before compiling the packages: <c>USE="mysql imap libwww maildir 80before compiling the packages: <c>USE="mysql imap libwww maildir
162 162
163<pre caption="Starting postfix for the first time"> 163<pre caption="Starting postfix for the first time">
164# <i>/usr/bin/newaliases</i> 164# <i>/usr/bin/newaliases</i>
165<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
166when you update or install aliases.)</comment> 166when you update or install aliases.)</comment>
167 167
168# <i>/etc/init.d/postfix start</i> 168# <i>/etc/init.d/postfix start</i>
169</pre> 169</pre>
170 170
171<p> 171<p>
172Now 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
236<section> 236<section>
237<body> 237<body>
238 238
239<p> 239<p>
240Next 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
241actually 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
242information to mysql for authentication of smtp users. For this howto, we'll 242that information to mysql for authentication of smtp users. For this howto,
243not 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
244a 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
245end anyway. 245mysql in the end anyway.
246</p> 246</p>
247 247
248<pre caption="Configuring and installing the cyrus-sasl ebuild"> 248<pre caption="Configuring and installing the cyrus-sasl ebuild">
249# <i>emerge cyrus-sasl</i> 249# <i>emerge cyrus-sasl</i>
250</pre> 250</pre>
336smtpd_sasl_local_domain appends a domain name to clients using 336smtpd_sasl_local_domain appends a domain name to clients using
337smtp-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
338mangled by postfix and be unable to auth.)</comment> 338mangled by postfix and be unable to auth.)</comment>
339 339
340smtpd_recipient_restrictions = 340smtpd_recipient_restrictions =
341 permit_sasl_authenticated, 341 permit_sasl_authenticated,
342 permit_mynetworks, 342 permit_mynetworks,
343 reject_unauth_destination 343 reject_unauth_destination
344
345 344
346<comment>(The next two options enable outgoing encryption.)</comment> 345<comment>(The next two options enable outgoing encryption.)</comment>
347smtp_use_tls = yes 346smtp_use_tls = yes
348smtp_tls_note_starttls_offer = yes 347smtp_tls_note_starttls_offer = yes
349smtpd_use_tls = yes 348smtpd_use_tls = yes
413user under which the virtual mailboxes will be hosted. For clarity's sake we 412user under which the virtual mailboxes will be hosted. For clarity's sake we
414will call this <e>vmail</e>: 413will call this <e>vmail</e>:
415</p> 414</p>
416 415
417<pre caption="Adding the vmail user"> 416<pre caption="Adding the vmail user">
418# <i>adduser -d /home/vmail -s /bin/false -m vmail</i> 417# <i>useradd -d /home/vmail -s /bin/false -m vmail</i>
419</pre> 418</pre>
420 419
421<p> 420<p>
422So now you've set up the vmail account. You can create multiple accounts if you 421So now you've set up the vmail account. You can create multiple accounts if you
423want (to keep some structure in your set of virtual mail accounts). The user id, 422want (to keep some structure in your set of virtual mail accounts). The user id,
428Next to the user account we also need to create the location where the mailboxes 427Next to the user account we also need to create the location where the mailboxes
429will reside: 428will reside:
430</p> 429</p>
431 430
432<pre caption="Creating mailboxes"> 431<pre caption="Creating mailboxes">
433# <i>mkdir /home/vmail/virt-domain.com/foo</i> 432# <i>mkdir -p /home/vmail/virt-domain.com/foo</i>
434# <i>chown -R vmail:vmail /home/vmail/virt-domain.com</i> 433# <i>chown -R vmail:vmail /home/vmail/virt-domain.com</i>
435# <i>maildirmake /home/vmail/virt-domain.com/foo/.maildir</i> 434# <i>maildirmake /home/vmail/virt-domain.com/foo/.maildir</i>
436</pre> 435</pre>
437 436
438</body> 437</body>
453<pre caption="Installing and configuring MySQL"> 452<pre caption="Installing and configuring MySQL">
454# <i>emerge mysql</i> 453# <i>emerge mysql</i>
455 454
456# <i>/usr/bin/mysql_install_db</i> 455# <i>/usr/bin/mysql_install_db</i>
457<comment>(After this command runs follow the onscreen directions 456<comment>(After this command runs follow the onscreen directions
458for adding a root password with mysql, 457for adding a root password with mysql, otherwise your db will
459not mysqladmin, otherwise your db will be wide open.)</comment> 458be wide open.)</comment>
460 459
461# <i>/etc/init.d/mysql start</i> 460# <i>/etc/init.d/mysql start</i>
462# <i>mysqladmin -u root -p create mailsql</i> 461# <i>mysqladmin -u root -p create mailsql</i>
463# <i>mysql -u root -p mailsql &lt; genericmailsql.sql</i> 462# <i>mysql -u root -p mailsql &lt; genericmailsql.sql</i>
464
465# <i>mysql -u root -p mysql</i> 463# <i>mysql -u root -p mysql</i>
466mysql> <i>GRANT SELECT,INSERT,UPDATE,DELETE</i> 464mysql> <i>GRANT SELECT,INSERT,UPDATE,DELETE</i>
467 -> <i>ON mailsql.*</i> 465 -> <i>ON mailsql.*</i>
468 -> <i>TO mailsql@localhost</i> 466 -> <i>TO mailsql@localhost</i>
469 -> <i>IDENTIFIED BY '$password';</i> 467 -> <i>IDENTIFIED BY '$password';</i>
470Query OK, 0 rows affected (0.02 sec) 468Query OK, 0 rows affected (0.02 sec)
471 469
472mysql> <i>FLUSH PRIVILEGES;</i> 470mysql> <i>FLUSH PRIVILEGES;</i>
473Query OK, 0 rows affected (0.00 sec) 471Query OK, 0 rows affected (0.00 sec)
474 472
493 <li>users - all user account information</li> 491 <li>users - all user account information</li>
494 <li>virtual - virtual domain email alias maps</li> 492 <li>virtual - virtual domain email alias maps</li>
495</ul> 493</ul>
496 494
497<pre caption="alias table sample"> 495<pre caption="alias table sample">
498id alias destination 496id alias destination
4991 root foo@bar.com 4971 root foo@bar.com
5002 postmaster foo@bar.com 4982 postmaster foo@bar.com
501</pre> 499</pre>
502 500
503<pre caption="user table sample"> 501<pre caption="user table sample">
504<comment>(Line wrapped for clarity.)</comment> 502<comment>(Line wrapped for clarity.)</comment>
505id email clear name uid gid homedir \ 503id email clear name uid gid homedir \
506 maildir quota postfix 504 maildir quota postfix
50710 foo@virt-domain.com $password realname virtid virtid /home/vmail \ 50510 foo@virt-domain.com $password realname virtid virtid /home/vmail \
508 /home/vmail/virt-domain.com/foo/.maildir/ y 506 /home/vmail/virt-domain.com/foo/.maildir/ y
50913 foo@bar.com $password realname localid localid /home/foo \ 50713 foo@bar.com $password realname localid localid /home/foo \
510 /home/foo/.maildir/ y 508 /home/foo/.maildir/ y
511</pre> 509</pre>
512 510
513<p> 511<p>
514The 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>
515user and group. 513user and group.
5201 bar.com local: 5181 bar.com local:
5212 virt-domain.com virtual: 5192 virt-domain.com virtual:
522</pre> 520</pre>
523 521
524<pre caption="virtual table sample"> 522<pre caption="virtual table sample">
525id email destination 523id email destination
5263 root@virt-domain.com other@email.address 5243 root@virt-domain.com other@email.address
527</pre> 525</pre>
528 526
529</body> 527</body>
530</section> 528</section>
531</chapter> 529</chapter>
571 569
572<pre caption="Install Apache SSL certificates"> 570<pre caption="Install Apache SSL certificates">
573# <i>cp /etc/ssl/misc/new.cert.cert /etc/apache2/ssl/</i> 571# <i>cp /etc/ssl/misc/new.cert.cert /etc/apache2/ssl/</i>
574# <i>cp /etc/ssl/misc/new.cert.key /etc/apache2/ssl/</i> 572# <i>cp /etc/ssl/misc/new.cert.key /etc/apache2/ssl/</i>
575# <i>cd /etc/apache2/vhosts.d</i> 573# <i>cd /etc/apache2/vhosts.d</i>
576<comment>(Check if you have an ssl-vhost template already. 574<comment>(Check if you have an ssl-vhost template already.
577 Copy that one instead of the default_vhost if that is the case)</comment> 575 Copy that one instead of the default_vhost if that is the case)</comment>
578# <i>cp 00_default_vhost.conf ssl-vhost.conf</i> 576# <i>cp 00_default_vhost.conf ssl-vhost.conf</i>
579# <i>nano -w ssl-vhost.conf</i> 577# <i>nano -w ssl-vhost.conf</i>
580 578
581<comment>(Change the following parameters)</comment> 579<comment>(Change the following parameters)</comment>
683 681
684<pre caption="/etc/postfix/mysql-aliases.cf"> 682<pre caption="/etc/postfix/mysql-aliases.cf">
685# <i>nano -w /etc/postfix/mysql-aliases.cf</i> 683# <i>nano -w /etc/postfix/mysql-aliases.cf</i>
686# mysql-aliases.cf 684# mysql-aliases.cf
687 685
688user = mailsql 686user = mailsql
689password = $password 687password = $password
690dbname = mailsql 688dbname = mailsql
691table = alias 689table = alias
692select_field = destination 690select_field = destination
693where_field = alias 691where_field = alias
694hosts = unix:/var/run/mysqld/mysqld.sock 692hosts = unix:/var/run/mysqld/mysqld.sock
695</pre> 693</pre>
696 694
697<pre caption="/etc/postfix/mysql-relocated.cf"> 695<pre caption="/etc/postfix/mysql-relocated.cf">
698# <i>nano -w /etc/postfix/mysql-relocated.cf</i> 696# <i>nano -w /etc/postfix/mysql-relocated.cf</i>
699# mysql-relocated.cf 697# mysql-relocated.cf
700 698
701user = mailsql 699user = mailsql
702password = $password 700password = $password
703dbname = mailsql 701dbname = mailsql
704table = relocated 702table = relocated
705select_field = destination 703select_field = destination
706where_field = email 704where_field = email
707hosts = unix:/var/run/mysqld/mysqld.sock 705hosts = unix:/var/run/mysqld/mysqld.sock
708</pre> 706</pre>
709 707
710<pre caption="/etc/postfix/mysql-transport.cf (optional)"> 708<pre caption="/etc/postfix/mysql-transport.cf (optional)">
711# <i>nano -w /etc/postfix/mysql-transport.cf</i> 709# <i>nano -w /etc/postfix/mysql-transport.cf</i>
712# mysql-transport.cf 710# mysql-transport.cf
713 711
714user = mailsql 712user = mailsql
715password = $password 713password = $password
716dbname = mailsql 714dbname = mailsql
717table = transport 715table = transport
718select_field = destination 716select_field = destination
719where_field = domain 717where_field = domain
720hosts = unix:/var/run/mysqld/mysqld.sock 718hosts = unix:/var/run/mysqld/mysqld.sock
721</pre> 719</pre>
722 720
723<pre caption="/etc/postfix/mysql-virtual-gid.cf (optional)"> 721<pre caption="/etc/postfix/mysql-virtual-gid.cf (optional)">
724# <i>nano -w /etc/postfix/mysql-virtual-gid.cf</i> 722# <i>nano -w /etc/postfix/mysql-virtual-gid.cf</i>
725# mysql-virtual-gid.cf 723# mysql-virtual-gid.cf
726 724
727user = mailsql 725user = mailsql
728password = $password 726password = $password
729dbname = mailsql 727dbname = mailsql
730table = users 728table = users
731select_field = gid 729select_field = gid
732where_field = email 730where_field = email
733additional_conditions = and postfix = 'y' 731additional_conditions = and postfix = 'y'
734hosts = unix:/var/run/mysqld/mysqld.sock 732hosts = unix:/var/run/mysqld/mysqld.sock
735</pre> 733</pre>
736 734
737<pre caption="/etc/postfix/mysql-virtual-maps.cf"> 735<pre caption="/etc/postfix/mysql-virtual-maps.cf">
738# <i>nano -w /etc/postfix/mysql-virtual-maps.cf</i> 736# <i>nano -w /etc/postfix/mysql-virtual-maps.cf</i>
739# mysql-virtual-maps.cf 737# mysql-virtual-maps.cf
740 738
741user = mailsql 739user = mailsql
742password = $password 740password = $password
743dbname = mailsql 741dbname = mailsql
744table = users 742table = users
745select_field = maildir 743select_field = maildir
746where_field = email 744where_field = email
747additional_conditions = and postfix = 'y' 745additional_conditions = and postfix = 'y'
748hosts = unix:/var/run/mysqld/mysqld.sock 746hosts = unix:/var/run/mysqld/mysqld.sock
749</pre> 747</pre>
750 748
751<pre caption="/etc/postfix/mysql-virtual-uid.cf (optional)"> 749<pre caption="/etc/postfix/mysql-virtual-uid.cf (optional)">
755user = mailsql 753user = mailsql
756password = $password 754password = $password
757dbname = mailsql 755dbname = mailsql
758table = users 756table = users
759select_field = uid 757select_field = uid
760where_field = email 758where_field = email
761additional_conditions = and postfix = 'y' 759additional_conditions = and postfix = 'y'
762hosts = unix:/var/run/mysqld/mysqld.sock 760hosts = unix:/var/run/mysqld/mysqld.sock
763</pre> 761</pre>
764 762
765<pre caption="/etc/postfix/mysql-virtual.cf"> 763<pre caption="/etc/postfix/mysql-virtual.cf">
766# <i>nano -w /etc/postfix/mysql-virtual.cf</i> 764# <i>nano -w /etc/postfix/mysql-virtual.cf</i>
767# mysql-virtual.cf 765# mysql-virtual.cf
768 766
769user = mailsql 767user = mailsql
770password = $password 768password = $password
771dbname = mailsql 769dbname = mailsql
772table = virtual 770table = virtual
773select_field = destination 771select_field = destination
774where_field = email 772where_field = email
775hosts = unix:/var/run/mysqld/mysqld.sock 773hosts = unix:/var/run/mysqld/mysqld.sock
776</pre> 774</pre>
777 775
778<p> 776<p>
779Lastly, edit <path>/etc/postfix/main.cf</path> one more time. 777Lastly, edit <path>/etc/postfix/main.cf</path> one more time.
780</p> 778</p>
787 785
788local_transport = local 786local_transport = local
789local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname 787local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname
790 788
791virtual_transport = virtual 789virtual_transport = virtual
792<comment>(The domains listed by the mydestination should not be listed in 790<comment>(The domains listed by the mydestination should not be listed in
793 the virtual_mailbox_domains parameter)</comment> 791 the virtual_mailbox_domains parameter)</comment>
794virtual_mailbox_domains = virt-domain.com, $other-virtual-domain.com 792virtual_mailbox_domains = virt-domain.com, $other-virtual-domain.com
795 793
796virtual_minimum_uid = 1000 794virtual_minimum_uid = 1000
797<comment>(Substitute $vmail-gid with the GID of the vmail group)</comment> 795<comment>(Substitute $vmail-gid with the GID of the vmail group)</comment>
890</pre> 888</pre>
891 889
892<pre caption="mailman config: mm_cfg.py"> 890<pre caption="mailman config: mm_cfg.py">
893# <i>nano -w /usr/local/mailman/Mailman/mm_cfg.py</i> 891# <i>nano -w /usr/local/mailman/Mailman/mm_cfg.py</i>
894MTA = "Postfix" 892MTA = "Postfix"
895POSTFIX_STYLE_VIRTUAL_DOMAINS = ['virt-domain.com', 'virt.domain2.com'] 893POSTFIX_STYLE_VIRTUAL_DOMAINS = ['virt-domain.com', 'virt.domain2.com']
896add_virtualhost('www.virt.domain.com', 'virt.domain.com') 894add_virtualhost('www.virt.domain.com', 'virt.domain.com')
897add_virtualhost('www.virt.domain2.com', 'virt.domain2.com') 895add_virtualhost('www.virt.domain2.com', 'virt.domain2.com')
898<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>
899</pre> 897</pre>
900 898
945owner_request_special = no 943owner_request_special = no
946recipient_delimiter = + 944recipient_delimiter = +
947<comment>(Read README.POSTFIX.gz for details on this.)</comment> 945<comment>(Read README.POSTFIX.gz for details on this.)</comment>
948 946
949alias_maps = 947alias_maps =
950 hash:/usr/local/mailman/data/aliases, 948 hash:/usr/local/mailman/data/aliases,
951 mysql:/etc/postfix/mysql-aliases.cf 949 mysql:/etc/postfix/mysql-aliases.cf
952 950
953virtual_alias_maps = 951virtual_alias_maps =
954 hash:/usr/local/mailman/data/virtual-mailman, 952 hash:/usr/local/mailman/data/virtual-mailman,
955 mysql:/etc/postfix/mysql-virtual.cf 953 mysql:/etc/postfix/mysql-virtual.cf
956<comment>(This adds mailman alias file support to postfix 954<comment>(This adds mailman alias file support to postfix
957You may of course use the mysql tables for this, 955You may of course use the mysql tables for this,
958but I hate doing that by hand. Also, if you are not 956but I hate doing that by hand. Also, if you are not
959using virtual domains, adding the virtual alias maps 957using virtual domains, adding the virtual alias maps
960to postfix may cause problems, be warned.)</comment> 958to postfix may cause problems, be warned.)</comment>
1198 <li> 1196 <li>
1199 <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
1200 google, which has never failed me 1198 google, which has never failed me
1201 </li> 1199 </li>
1202 <li> 1200 <li>
1203 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
1204 place to go for help. 1202 link="irc://irc.gentoo.org/gentoo">#gentoo</uri>. IRC is a great place to go
1203 for help.
1205 </li> 1204 </li>
1206</ul> 1205</ul>
1207 1206
1208</body> 1207</body>
1209</section> 1208</section>

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

  ViewVC Help
Powered by ViewVC 1.1.20