/[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.28 Revision 1.34
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.28 2004/03/04 18:24:44 swift Exp $ --> 2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/virt-mail-howto.xml,v 1.34 2004/09/30 12:10:15 swift Exp $ -->
3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4 4
5<guide link=" /doc/en/virt-mail-howto.xml" > 5<guide link=" /doc/en/virt-mail-howto.xml" >
6<title>Virtual Mailhosting System with Postfix Guide</title> 6<title>Virtual Mailhosting System with Postfix Guide</title>
7<author title="Author" > 7<author title="Author" >
12</author> 12</author>
13<author title="Editor"> 13<author title="Editor">
14<mail link="klasikahl@gentoo.org" >Zack Gilburd</mail> 14<mail link="klasikahl@gentoo.org" >Zack Gilburd</mail>
15</author> 15</author>
16<abstract>This document details how to create a virtual mailhosting system based upon postfix, mysql, courier-imap, and cyrus-sasl. </abstract> 16<abstract>This document details how to create a virtual mailhosting system based upon postfix, mysql, courier-imap, and cyrus-sasl. </abstract>
17<version>1.0.10</version> 17<version>1.0.12</version>
18<date>March 4, 2004</date> 18<date>September 30, 2004</date>
19<!-- 19<!--
20 20
21Contents 21Contents
22 22
23I. Introduction 23I. Introduction
45<p>This howto will show you how to set up with a mail system capable of handling mail for as many domains as your hardware can handle, supports virtual mail users that don't require shell accounts, has domain specific user names, can authenticate web, imap, smtp, and pop3 clients against a single database, utilizes ssl for transport layer security, has a web interface, can handle mailing lists for any domain on the machine, and is controlled by a nice, central and easy mysql database. </p> 45<p>This howto will show you how to set up with a mail system capable of handling mail for as many domains as your hardware can handle, supports virtual mail users that don't require shell accounts, has domain specific user names, can authenticate web, imap, smtp, and pop3 clients against a single database, utilizes ssl for transport layer security, has a web interface, can handle mailing lists for any domain on the machine, and is controlled by a nice, central and easy mysql database. </p>
46<p>There are quite a variety of ways to go about setting up a virtual mailhosting system. With so may options, another may be the best choice for your specific needs. Consider investigating <uri>http://www.qmail.org/</uri> and <uri>http://www.exim.org/</uri> to explore your options. </p> 46<p>There are quite a variety of ways to go about setting up a virtual mailhosting system. With so may options, another may be the best choice for your specific needs. Consider investigating <uri>http://www.qmail.org/</uri> and <uri>http://www.exim.org/</uri> to explore your options. </p>
47<p>The following packages are used in this setup: 47<p>The following packages are used in this setup:
48 48
49 apache, courier-imap, pam_mysql, postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and mailman.</p> 49 apache, courier-imap, pam_mysql, postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and mailman.</p>
50<p>Make sure to turn on the following USE variables in <path>/etc/make.conf</path> before compiling the packages: <c>USE=&quot;mysql imap libwww maildir sasl ssl&quot;</c>. Otherwise you will most likely have to recompile things to get the support you need for all the protocols. Further, it's a good idea to turn off any other mail and network variables, like ipv6.</p> 50<p>Make sure to turn on the following USE variables in <path>/etc/make.conf</path> before compiling the packages: <c>USE=&quot;mysql pam-mysql imap libwww maildir sasl ssl&quot;</c>. Otherwise you will most likely have to recompile things to get the support you need for all the protocols. Further, it's a good idea to turn off any other mail and network variables, like ipv6.</p>
51<impo>This howto was written for postfix-2.0.x. If you are using postfix &lt; 2 some of the variables in this document will be different. It is recommended that you upgrade. Some other packages included in this howto are version sensitive as well. You are advised to read the documentation included with packages if you run into issues with this.</impo> 51<impo>This howto was written for postfix-2.0.x. If you are using postfix &lt; 2 some of the variables in this document will be different. It is recommended that you upgrade. Some other packages included in this howto are version sensitive as well. You are advised to read the documentation included with packages if you run into issues with this.</impo>
52<impo>This document uses apache-1.3.x. Apache-2 has been marked stable in portage. However there are still a number of issues with php integration. Until php support in apache-2.0.x is marked stable, this guide will continue to use the 1.3.x version.</impo> 52<impo>This document uses apache-1.3.x. Apache-2 has been marked stable in portage. However there are still a number of issues with php integration. Until php support in apache-2.0.x is marked stable, this guide will continue to use the 1.3.x version.</impo>
53<impo>You need a domain name to run a public mail server, or at least an MX record for a domain. Ideally you would have control of at least two domains to take advantage of your new virtual domain functionality.</impo> 53<impo>You need a domain name to run a public mail server, or at least an MX record for a domain. Ideally you would have control of at least two domains to take advantage of your new virtual domain functionality.</impo>
54<impo>Make sure <path>/etc/hostname</path> is set to the right hostname for your mail server. Verify your hostname is set correctly with <c>hostname</c>. Also verify that there are no conflicting entries in <path>/etc/hosts</path>.</impo> 54<impo>Make sure <path>/etc/hostname</path> is set to the right hostname for your mail server. Verify your hostname is set correctly with <c>hostname</c>. Also verify that there are no conflicting entries in <path>/etc/hosts</path>.</impo>
55<note>It is recommended that you read this entire document and familiarize yourself with all the steps before attempting the install. If you run into problems with any of the steps, check the troubleshooting guide at the end of this document. Also, not all the referenced packages are necessary, this set up is very flexible. For instance, if you do not desire a web interface, feel free to skip the squirrelmail section.</note> 55<note>It is recommended that you read this entire document and familiarize yourself with all the steps before attempting the install. If you run into problems with any of the steps, check the troubleshooting guide at the end of this document. Also, not all the referenced packages are necessary, this set up is very flexible. For instance, if you do not desire a web interface, feel free to skip the squirrelmail section.</note>
80# (yes) (yes) (yes) (never) (50) 80# (yes) (yes) (yes) (never) (50)
81# 81#
82========================================================================== 82==========================================================================
83smtp inet n - n - - smtpd -v 83smtp inet n - n - - smtpd -v
84 84
85<codenote>Just add the <c>-v</c> after the smtpd in the above line</codenote> 85<codenote>Just add the "-v" after the smtpd in the above line</codenote>
86</pre> 86</pre>
87<p>Next, edit <path>/etc/mail/aliases</path> to add your local aliases. There should at least be an alias for root like: <c>root: your@email.address</c>.</p> 87<p>Next, edit <path>/etc/mail/aliases</path> to add your local aliases. There should at least be an alias for root like: <c>root: your@email.address</c>.</p>
88<pre caption="Starting postfix for the first time" > 88<pre caption="Starting postfix for the first time" >
89# <i>/usr/bin/newaliases</i> 89# <i>/usr/bin/newaliases</i>
90<codenote>This will install the new aliases. You only need to do this </codenote> 90<codenote>This will install the new aliases. You only need to do this </codenote>
138<codenote>so we need to turn them off for this build.</codenote> 138<codenote>so we need to turn them off for this build.</codenote>
139</pre> 139</pre>
140<p>Next, edit <path>/etc/sasl2/smtpd.conf</path>.</p> 140<p>Next, edit <path>/etc/sasl2/smtpd.conf</path>.</p>
141<pre caption="Starting sasl" > 141<pre caption="Starting sasl" >
142# <i>nano -w /etc/sasl2/smtpd.conf</i> 142# <i>nano -w /etc/sasl2/smtpd.conf</i>
143pwcheck_method: auxprop
144auxprop_plugin: sql
145sql_engine: mysql
146sql_hostnames: localhost
147sql_user: mailsql
148sql_passwd: <comment>&lt;password&gt;</comment>
149sql_database: mailsql
150sql_select: select clear from users where email = '%u@%r'
151mech_list: plain login
143pwcheck_method: saslauthd 152pwcheck_method: saslauthd
144mech_list: LOGIN PLAIN 153mech_list: LOGIN PLAIN
145<codenote>It's important to turn off auth methods we are not using.</codenote> 154<codenote>It's important to turn off auth methods we are not using.</codenote>
146<codenote>They cause problems for some mail clients.</codenote> 155<codenote>They cause problems for some mail clients.</codenote>
147# <i>/etc/init.d/saslauthd start</i> 156# <i>/etc/init.d/saslauthd start</i>
294 -> <i>quit</i> 303 -> <i>quit</i>
295<codenote>Verify that the new mailsql user can connect to the mysql server.</codenote> 304<codenote>Verify that the new mailsql user can connect to the mysql server.</codenote>
296 305
297# <i>mysql -u mailsql -p mailsql</i> 306# <i>mysql -u mailsql -p mailsql</i>
298</pre> 307</pre>
308
309<p>
299<p>Your new database has default values and tables set up for two domains. The following tables are included: 310Your new database has default values and tables set up for two domains. The following tables are included:
311</p>
312
300 <ul> 313<ul>
301<li>alias - local email alias and mailman alias information.</li> 314<li>alias - local email alias and mailman alias information.</li>
302<li>relocated - relocated user email address maps</li> 315<li>relocated - relocated user email address maps</li>
303<li>transport - default mail transport information for all domains you are hosting</li> 316<li>transport - default mail transport information for all domains you are hosting</li>
304<li>users - all user account information</li> 317<li>users - all user account information</li>
305<li>virtual - virtual domain email alias maps</li> 318<li>virtual - virtual domain email alias maps</li>
306</ul> 319</ul>
307</p> 320
308<pre caption="alias table sample" > 321<pre caption="alias table sample" >
309id alias destination 322id alias destination
3101 root foo@bar.com 3231 root foo@bar.com
3112 postmaster foo@bar.com 3242 postmaster foo@bar.com
312</pre> 325</pre>
338<p>Next we'll set up apache and add an interface to interact with the database more easily. </p> 351<p>Next we'll set up apache and add an interface to interact with the database more easily. </p>
339<pre caption="Setting up apache and phpmyadmin" > 352<pre caption="Setting up apache and phpmyadmin" >
340# <i>emerge apache mod_php phpmyadmin</i> 353# <i>emerge apache mod_php phpmyadmin</i>
341</pre> 354</pre>
342<p>There are plenty of guides out there about how to set up apache with php. Like this one: <uri>http://www.linuxguruz.org/z.php?id=31</uri>. There are also numerous posts on <uri>http://forums.gentoo.org</uri> detailing how to solve problems with the installation (search for 'apache php'). So, that said, I'm not going to cover it here. Set up the apache and php installs, then continue with this howto. Now, a word for the wise: .htaccess the directory that you put phpmyadmin in. If you do not do this, search engine spiders will come along and index the page which in turn will mean that anyone will be able to find your phpmyadmin page via google and in turn be able to come change your database however they want which is <e>BAD!</e> There are many howtos on this including: <uri>http://www.csoft.net/docs/micro/htaccess.html.en</uri>.</p> 355<p>There are plenty of guides out there about how to set up apache with php. Like this one: <uri>http://www.linuxguruz.org/z.php?id=31</uri>. There are also numerous posts on <uri>http://forums.gentoo.org</uri> detailing how to solve problems with the installation (search for 'apache php'). So, that said, I'm not going to cover it here. Set up the apache and php installs, then continue with this howto. Now, a word for the wise: .htaccess the directory that you put phpmyadmin in. If you do not do this, search engine spiders will come along and index the page which in turn will mean that anyone will be able to find your phpmyadmin page via google and in turn be able to come change your database however they want which is <e>BAD!</e> There are many howtos on this including: <uri>http://www.csoft.net/docs/micro/htaccess.html.en</uri>.</p>
356
357<p>
343<p>Now we're going to install the Apache certificates we made previously. The Apache-SSL directives that you need to use the resulting cert are: 358Now we're going to install the Apache certificates we made previously. The Apache-SSL directives that you need to use the resulting cert are:
359</p>
360
344 <ul> 361<ul>
345<li>SSLCertificateFile /path/to/certs/new.cert.cert</li> 362<li>SSLCertificateFile /path/to/certs/new.cert.cert</li>
346<li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li> 363<li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li>
347</ul> 364</ul>
348</p> 365
349<pre caption="Install Apache SSL certificates" > 366<pre caption="Install Apache SSL certificates" >
350# <i>cp /etc/ssl/misc/new.cert.cert /etc/apache/conf/ssl/</i> 367# <i>cp /etc/ssl/misc/new.cert.cert /etc/apache/conf/ssl/</i>
351# <i>cp /etc/ssl/misc/new.cert.key /etc/apache/conf/ssl/</i> 368# <i>cp /etc/ssl/misc/new.cert.key /etc/apache/conf/ssl/</i>
352# <i>nano -w /etc/apache/conf/vhosts/ssl.default-vhost.conf</i> 369# <i>nano -w /etc/apache/conf/vhosts/ssl.default-vhost.conf</i>
353<codenote>Change the following parameters</codenote> 370<codenote>Change the following parameters</codenote>
385<pre caption="Adding the vmail user" > 402<pre caption="Adding the vmail user" >
386# <i>adduser -d /home/vmail -s /bin/false vmail</i> 403# <i>adduser -d /home/vmail -s /bin/false vmail</i>
387# <i>uid=`cat /etc/passwd | grep vmail | cut -f 3 -d :`</i> 404# <i>uid=`cat /etc/passwd | grep vmail | cut -f 3 -d :`</i>
388# <i>groupadd -g $uid vmail</i> 405# <i>groupadd -g $uid vmail</i>
389# <i>mkdir /home/vmail</i> 406# <i>mkdir /home/vmail</i>
390# <i>chown vmail. /home/vmail</i> 407# <i>chown vmail: /home/vmail</i>
391</pre> 408</pre>
392<p>So now when you're setting up vmail accounts, use the vmail uid, gid, and homedir. When you're setting up local accounts, use that users uid, gid, and homedir. We've been meaning to create a php admin page for this setup but haven't gotten around to it yet, as phpmyadmin generally works fine for us.</p> 409<p>So now when you're setting up vmail accounts, use the vmail uid, gid, and homedir. When you're setting up local accounts, use that users uid, gid, and homedir. We've been meaning to create a php admin page for this setup but haven't gotten around to it yet, as phpmyadmin generally works fine for us.</p>
393</body> 410</body>
394</section> 411</section>
395</chapter> 412</chapter>
579<pre> 596<pre>
580# <i>emerge squirrelmail</i> 597# <i>emerge squirrelmail</i>
581<codenote>I like to add a link to the htdocs space for a shorter url.</codenote> 598<codenote>I like to add a link to the htdocs space for a shorter url.</codenote>
582 599
583# <i>ln -s /var/www/localhost/htdocs/squirrelmail/ /var/www/localhost/htdocs/mail</i> 600# <i>ln -s /var/www/localhost/htdocs/squirrelmail/ /var/www/localhost/htdocs/mail</i>
584# <i>cd /var/www/localhost/htdocs/mail/conf</i> 601# <i>cd /var/www/localhost/htdocs/mail/config</i>
585# <i>./conf.pl</i> 602# <i>perl ./conf.pl</i>
586<codenote>Change your Organization, Server, and Folder settings for squirrelmail.</codenote> 603<codenote>Change your Organization, Server, and Folder settings for squirrelmail.</codenote>
587<codenote>Now you should be able to login to squirrelmail, again - with your full email address,</codenote> 604<codenote>Now you should be able to login to squirrelmail, again - with your full email address,</codenote>
588<codenote>and use your new webmail setup.</codenote> 605<codenote>and use your new webmail setup.</codenote>
589</pre> 606</pre>
590</body> 607</body>
792</section> 809</section>
793<section> 810<section>
794<title>Step 7: Research</title> 811<title>Step 7: Research</title>
795<body> 812<body>
796<p>Once you have the information, if you can diagnose and fix the problem, great! If not, you'll probably need to go digging on the net for information that will help you fix it. Here's a list of sites you can check to see if your error has already been resolved. There's also a really good howto on setting up smtp-auth which contains some great debugging ideas.</p> 813<p>Once you have the information, if you can diagnose and fix the problem, great! If not, you'll probably need to go digging on the net for information that will help you fix it. Here's a list of sites you can check to see if your error has already been resolved. There's also a really good howto on setting up smtp-auth which contains some great debugging ideas.</p>
797<p> 814
798<ul> 815<ul>
799<li> 816<li>
800<uri>http://forums.gentoo.org/</uri> - Great forums for gentoo users</li> 817<uri>http://forums.gentoo.org/</uri> - Great forums for gentoo users</li>
801<li> 818<li>
802<uri>http://bugs.gentoo.org/</uri> - Bugs database for gentoo - great place to look for specific errors</li> 819<uri>http://bugs.gentoo.org/</uri> - Bugs database for gentoo - great place to look for specific errors</li>
808<uri>http://sourceforge.net/mailarchive/forum.php?forum_id=6705</uri> - Courier-imap mailing list archives - not searchable</li> 825<uri>http://sourceforge.net/mailarchive/forum.php?forum_id=6705</uri> - Courier-imap mailing list archives - not searchable</li>
809<li> 826<li>
810<uri>http://www.google.com/</uri> - If all else fails, there's always google, which has never failed me</li> 827<uri>http://www.google.com/</uri> - If all else fails, there's always google, which has never failed me</li>
811<li>I also spend a lot of time on irc.freenode.net #gentoo. Irc is a great place to go for help.</li> 828<li>I also spend a lot of time on irc.freenode.net #gentoo. Irc is a great place to go for help.</li>
812</ul> 829</ul>
813</p> 830
814</body> 831</body>
815</section> 832</section>
816</chapter> 833</chapter>
817</guide> 834</guide>
818 835

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.34

  ViewVC Help
Powered by ViewVC 1.1.20