/[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.37
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.37 2004/11/19 08:28:14 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.15</version>
18<date>March 4, 2004</date> 18<date>November 19, 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>
131<section> 131<section>
132<body> 132<body>
133<p>Next we're going to install cyrus-sasl. Sasl is going to play the role of actually passing your auth variables to pam, which will in turn pass that information to mysql for authentication of smtp users. For this howto, we'll not even try to verify that sasl is working until mysql is set up and contains a test user. Which is fine since we'll be authenticating against mysql in the end anyway.</p> 133<p>Next we're going to install cyrus-sasl. Sasl is going to play the role of actually passing your auth variables to pam, which will in turn pass that information to mysql for authentication of smtp users. For this howto, we'll not even try to verify that sasl is working until mysql is set up and contains a test user. Which is fine since we'll be authenticating against mysql in the end anyway.</p>
134<note>Now for some reason, sasl will not play nicely with pam against the shadow file. I banged my head against this problem for, well, a long time. If anyone knows why sasl will not auth against the shadow file in its current gentoo incarnation, please <mail link="ken@kickasskungfu.com" >email me</mail> as I'd love to hear a solution to this.</note> 134<note>Now for some reason, sasl will not play nicely with pam against the shadow file. I banged my head against this problem for, well, a long time. If anyone knows why sasl will not auth against the shadow file in its current gentoo incarnation, please <mail link="ken@kickasskungfu.com" >email me</mail> as I'd love to hear a solution to this.</note>
135<pre caption="Configuring and installing the cyrus-sasl ebuild" > 135<pre caption="Configuring and installing the cyrus-sasl ebuild" >
136# <i>USE='-ldap -mysql' emerge cyrus-sasl</i>
137<codenote>We don't have ldap and we're not using sasl's mysql capabilities </codenote> 136<comment>(We don't have ldap and we're using sasl's mysql capabilities
138<codenote>so we need to turn them off for this build.</codenote> 137 so we need to set the appropriate USE flags, but only if your USE flags
138 doesn't already contain the mysql USE flag and not the ldap one)</comment>
139# <i>mkdir /etc/portage</i>
140# <i>echo "dev-libs/cyrus-sasl -ldap mysql" &gt;&gt; /etc/portage/package.use</i>
141# <i>emerge cyrus-sasl</i>
139</pre> 142</pre>
140<p>Next, edit <path>/etc/sasl2/smtpd.conf</path>.</p> 143<p>Next, edit <path>/etc/sasl2/smtpd.conf</path>.</p>
141<pre caption="Starting sasl" > 144<pre caption="Starting sasl" >
142# <i>nano -w /etc/sasl2/smtpd.conf</i> 145# <i>nano -w /etc/sasl2/smtpd.conf</i>
146pwcheck_method: auxprop
147auxprop_plugin: sql
148sql_engine: mysql
149sql_hostnames: localhost
150sql_user: mailsql
151sql_passwd: <comment>&lt;password&gt;</comment>
152sql_database: mailsql
153sql_select: select clear from users where email = '%u@%r'
154mech_list: plain login
143pwcheck_method: saslauthd 155pwcheck_method: saslauthd
144mech_list: LOGIN PLAIN 156mech_list: LOGIN PLAIN
145<codenote>It's important to turn off auth methods we are not using.</codenote> 157<codenote>It's important to turn off auth methods we are not using.</codenote>
146<codenote>They cause problems for some mail clients.</codenote> 158<codenote>They cause problems for some mail clients.</codenote>
147# <i>/etc/init.d/saslauthd start</i> 159# <i>/etc/init.d/saslauthd start</i>
270</chapter> 282</chapter>
271<chapter> 283<chapter>
272<title>MySQL</title> 284<title>MySQL</title>
273<section> 285<section>
274<body> 286<body>
275<p>Next we're going to install and configure MySQL. You'll need the <uri link="http://kickasskungfu.com/~ken/genericmailsql.sql" >genericmailsql.sql</uri> dumpfile for this step.</p> 287<p>Next we're going to install and configure MySQL. You'll need the <uri link="http://dev.gentoo.org/~spyderous/dotfiles/genericmailsql.sql">genericmailsql.sql</uri> dumpfile for this step.</p>
276<pre caption="Installing and configuring MySQL" > 288<pre caption="Installing and configuring MySQL" >
277# <i>emerge mysql</i> 289# <i>emerge mysql</i>
278 290
279# <i>/usr/bin/mysql_install_db</i> 291# <i>/usr/bin/mysql_install_db</i>
280<codenote>After this command runs follow the onscreen directions</codenote> 292<codenote>After this command runs follow the onscreen directions</codenote>
294 -> <i>quit</i> 306 -> <i>quit</i>
295<codenote>Verify that the new mailsql user can connect to the mysql server.</codenote> 307<codenote>Verify that the new mailsql user can connect to the mysql server.</codenote>
296 308
297# <i>mysql -u mailsql -p mailsql</i> 309# <i>mysql -u mailsql -p mailsql</i>
298</pre> 310</pre>
311
312<p>
299<p>Your new database has default values and tables set up for two domains. The following tables are included: 313Your new database has default values and tables set up for two domains. The following tables are included:
314</p>
315
300 <ul> 316<ul>
301<li>alias - local email alias and mailman alias information.</li> 317<li>alias - local email alias and mailman alias information.</li>
302<li>relocated - relocated user email address maps</li> 318<li>relocated - relocated user email address maps</li>
303<li>transport - default mail transport information for all domains you are hosting</li> 319<li>transport - default mail transport information for all domains you are hosting</li>
304<li>users - all user account information</li> 320<li>users - all user account information</li>
305<li>virtual - virtual domain email alias maps</li> 321<li>virtual - virtual domain email alias maps</li>
306</ul> 322</ul>
307</p> 323
308<pre caption="alias table sample" > 324<pre caption="alias table sample" >
309id alias destination 325id alias destination
3101 root foo@bar.com 3261 root foo@bar.com
3112 postmaster foo@bar.com 3272 postmaster foo@bar.com
312</pre> 328</pre>
31710 foo@virt-bar.org $password realname virtid virtid /home/vmail \ 33310 foo@virt-bar.org $password realname virtid virtid /home/vmail \
318 /home/vmail/virt-bar.org/foo/.maildir/ y 334 /home/vmail/virt-bar.org/foo/.maildir/ y
31913 foo@bar.com $password realname localid localid /home/foo \ 33513 foo@bar.com $password realname localid localid /home/foo \
320 /home/foo/.maildir/ y 336 /home/foo/.maildir/ y
321</pre> 337</pre>
338
339<p>
340The values of the <c>virtid</c> uid and gid should be those of the <c>vmail</c>
341user and group.
342</p>
343
322<pre caption="transport table sample" > 344<pre caption="transport table sample" >
323id domain destination 345id domain destination
3241 bar.com local: 3461 bar.com local:
3252 virt-bar.org virtual: 3472 virt-bar.org virtual:
326</pre> 348</pre>
338<p>Next we'll set up apache and add an interface to interact with the database more easily. </p> 360<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" > 361<pre caption="Setting up apache and phpmyadmin" >
340# <i>emerge apache mod_php phpmyadmin</i> 362# <i>emerge apache mod_php phpmyadmin</i>
341</pre> 363</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> 364<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>
365
366<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: 367Now we're going to install the Apache certificates we made previously. The Apache-SSL directives that you need to use the resulting cert are:
368</p>
369
344 <ul> 370<ul>
345<li>SSLCertificateFile /path/to/certs/new.cert.cert</li> 371<li>SSLCertificateFile /path/to/certs/new.cert.cert</li>
346<li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li> 372<li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li>
347</ul> 373</ul>
348</p> 374
349<pre caption="Install Apache SSL certificates" > 375<pre caption="Install Apache SSL certificates" >
350# <i>cp /etc/ssl/misc/new.cert.cert /etc/apache/conf/ssl/</i> 376# <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> 377# <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> 378# <i>nano -w /etc/apache/conf/vhosts/ssl.default-vhost.conf</i>
353<codenote>Change the following parameters</codenote> 379<codenote>Change the following parameters</codenote>
385<pre caption="Adding the vmail user" > 411<pre caption="Adding the vmail user" >
386# <i>adduser -d /home/vmail -s /bin/false vmail</i> 412# <i>adduser -d /home/vmail -s /bin/false vmail</i>
387# <i>uid=`cat /etc/passwd | grep vmail | cut -f 3 -d :`</i> 413# <i>uid=`cat /etc/passwd | grep vmail | cut -f 3 -d :`</i>
388# <i>groupadd -g $uid vmail</i> 414# <i>groupadd -g $uid vmail</i>
389# <i>mkdir /home/vmail</i> 415# <i>mkdir /home/vmail</i>
390# <i>chown vmail. /home/vmail</i> 416# <i>chown vmail: /home/vmail</i>
391</pre> 417</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> 418<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> 419</body>
394</section> 420</section>
395</chapter> 421</chapter>
579<pre> 605<pre>
580# <i>emerge squirrelmail</i> 606# <i>emerge squirrelmail</i>
581<codenote>I like to add a link to the htdocs space for a shorter url.</codenote> 607<codenote>I like to add a link to the htdocs space for a shorter url.</codenote>
582 608
583# <i>ln -s /var/www/localhost/htdocs/squirrelmail/ /var/www/localhost/htdocs/mail</i> 609# <i>ln -s /var/www/localhost/htdocs/squirrelmail/ /var/www/localhost/htdocs/mail</i>
584# <i>cd /var/www/localhost/htdocs/mail/conf</i> 610# <i>cd /var/www/localhost/htdocs/mail/config</i>
585# <i>./conf.pl</i> 611# <i>perl ./conf.pl</i>
586<codenote>Change your Organization, Server, and Folder settings for squirrelmail.</codenote> 612<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> 613<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> 614<codenote>and use your new webmail setup.</codenote>
589</pre> 615</pre>
590</body> 616</body>
792</section> 818</section>
793<section> 819<section>
794<title>Step 7: Research</title> 820<title>Step 7: Research</title>
795<body> 821<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> 822<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> 823
798<ul> 824<ul>
799<li> 825<li>
800<uri>http://forums.gentoo.org/</uri> - Great forums for gentoo users</li> 826<uri>http://forums.gentoo.org/</uri> - Great forums for gentoo users</li>
801<li> 827<li>
802<uri>http://bugs.gentoo.org/</uri> - Bugs database for gentoo - great place to look for specific errors</li> 828<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> 834<uri>http://sourceforge.net/mailarchive/forum.php?forum_id=6705</uri> - Courier-imap mailing list archives - not searchable</li>
809<li> 835<li>
810<uri>http://www.google.com/</uri> - If all else fails, there's always google, which has never failed me</li> 836<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> 837<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> 838</ul>
813</p> 839
814</body> 840</body>
815</section> 841</section>
816</chapter> 842</chapter>
817</guide> 843</guide>
818 844

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

  ViewVC Help
Powered by ViewVC 1.1.20