| 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.44 2005/05/23 16:09:09 swift Exp $ --> |
2 | <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/virt-mail-howto.xml,v 1.45 2005/05/29 16:12:29 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 | |
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> |
| 11 | <author title="Author"> |
11 | <author title="Author"> |
| 12 | <mail link="ezra@revoltltd.org">Ezra Gorman</mail> |
12 | <mail link="ezra@revoltltd.org">Ezra Gorman</mail> |
| 13 | </author> |
13 | </author> |
| 14 | <author title="Editor"> |
14 | <author title="Editor"> |
| 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"> |
|
|
18 | <mail link="seather@scygro.za.net">Scygro</mail> |
|
|
19 | </author> |
| 17 | |
20 | |
| 18 | <abstract> |
21 | <abstract> |
| 19 | This document details how to create a virtual mailhosting system based upon |
22 | This document details how to create a virtual mailhosting system based upon |
| 20 | postfix, mysql, courier-imap, and cyrus-sasl. |
23 | postfix, mysql, courier-imap, and cyrus-sasl. |
| 21 | </abstract> |
24 | </abstract> |
| 22 | |
25 | |
| 23 | <version>1.0.21</version> |
26 | <version>1.0.22</version> |
| 24 | <date>2005-05-23</date> |
27 | <date>2005-05-29</date> |
| 25 | |
28 | |
| 26 | <!-- |
29 | <!-- |
| 27 | Contents |
30 | Contents |
| 28 | |
31 | |
| 29 | I. Introduction |
32 | I. Introduction |
| 30 | II. Postfix Basics |
33 | II. Postfix Basics |
| 31 | III. Courier-imap |
34 | III. Courier-imap |
| 32 | IV. Cyrus-sasl |
35 | IV. Cyrus-sasl |
| 33 | V. SSL Certificates for Postfix and Apache |
36 | V. SSL Certificates for Postfix and Apache |
| 34 | VI. Adding SSL and SASL support to Postfix |
37 | VI. Adding SSL and SASL support to Postfix |
| 35 | VII. MySQL |
38 | VII. MySQL |
| 36 | VIII. Apache and phpMyAdmin |
39 | VIII. Apache and phpMyAdmin |
| 37 | IX. The vmail user |
40 | IX. The vmail user |
| 38 | X. Configuring MySQL Authentication and vhosts |
41 | X. Configuring MySQL Authentication and vhosts |
| 39 | XI. Squirrelmail |
42 | XI. Squirrelmail |
| … | |
… | |
| 72 | users that don't require shell accounts, has domain specific user names, can |
75 | users that don't require shell accounts, has domain specific user names, can |
| 73 | authenticate web, imap, smtp, and pop3 clients against a single database, |
76 | authenticate web, imap, smtp, and pop3 clients against a single database, |
| 74 | utilizes ssl for transport layer security, has a web interface, can handle |
77 | utilizes ssl for transport layer security, has a web interface, can handle |
| 75 | mailing lists for any domain on the machine, and is controlled by a nice, |
78 | mailing lists for any domain on the machine, and is controlled by a nice, |
| 76 | central and easy mysql database. |
79 | central and easy mysql database. |
| 77 | </p> |
80 | </p> |
| 78 | |
81 | |
| 79 | <p> |
82 | <p> |
| 80 | There are quite a variety of ways to go about setting up a virtual mailhosting |
83 | There are quite a variety of ways to go about setting up a virtual mailhosting |
| 81 | system. With so may options, another may be the best choice for your specific |
84 | system. With so may options, another may be the best choice for your specific |
| 82 | needs. Consider investigating <uri>http://www.qmail.org/</uri> and |
85 | needs. Consider investigating <uri>http://www.qmail.org/</uri> and |
| 83 | <uri>http://www.exim.org/</uri> to explore your options. |
86 | <uri>http://www.exim.org/</uri> to explore your options. |
| 84 | </p> |
87 | </p> |
| 85 | |
88 | |
| 86 | <p> |
89 | <p> |
| 87 | The following packages are used in this setup: apache, courier-imap, pam_mysql, |
90 | The following packages are used in this setup: apache, courier-imap, courier-authlib |
| 88 | postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and |
91 | postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and |
| 89 | mailman. |
92 | mailman. |
| 90 | </p> |
93 | </p> |
| 91 | |
94 | |
| 92 | <p> |
95 | <p> |
| 93 | Make sure to turn on the following USE variables in <path>/etc/make.conf</path> |
96 | Make sure to turn on the following USE variables in <path>/etc/make.conf</path> |
| 94 | before compiling the packages: <c>USE="mysql pam-mysql imap libwww maildir |
97 | before compiling the packages: <c>USE="mysql imap libwww maildir |
| 95 | sasl ssl"</c>. Otherwise you will most likely have to recompile things to |
98 | sasl ssl"</c>. Otherwise you will most likely have to recompile things to |
| 96 | get the support you need for all the protocols. Further, it's a good idea to |
99 | get the support you need for all the protocols. Further, it's a good idea to |
| 97 | turn off any other mail and network variables, like ipv6. |
100 | turn off any other mail and network variables, like ipv6. |
| 98 | </p> |
101 | </p> |
| 99 | |
102 | |
| 100 | <impo> |
103 | <impo> |
| 101 | This howto was written for postfix-2.0.x. If you are using postfix < 2 some |
104 | This howto was written for postfix-2.0.x. If you are using postfix < 2 some |
| 102 | of the variables in this document will be different. It is recommended that you |
105 | of the variables in this document will be different. It is recommended that you |
| 103 | upgrade. Some other packages included in this howto are version sensitive as |
106 | upgrade. Some other packages included in this howto are version sensitive as |
| 104 | well. You are advised to read the documentation included with packages if you |
107 | well. You are advised to read the documentation included with packages if you |
| 105 | run into issues with this. |
108 | run into issues with this. |
| 106 | </impo> |
109 | </impo> |
| 107 | |
110 | |
| 108 | <impo> |
111 | <impo> |
| 109 | This document uses apache-1.3.x. Apache-2 has been marked stable in portage. |
112 | This document uses apache-1.3.x. Apache-2 has been marked stable in portage. |
| … | |
… | |
| 203 | |
206 | |
| 204 | <note> |
207 | <note> |
| 205 | I strongly recommend that you verify this basic postfix setup is functioning |
208 | I strongly recommend that you verify this basic postfix setup is functioning |
| 206 | before you progress to the next step of the howto. |
209 | before you progress to the next step of the howto. |
| 207 | </note> |
210 | </note> |
| 208 | |
211 | |
| 209 | </body> |
212 | </body> |
| 210 | </section> |
213 | </section> |
| 211 | </chapter> |
214 | </chapter> |
| 212 | |
215 | |
| 213 | <chapter> |
216 | <chapter> |
| 214 | <title>Courier-imap</title> |
217 | <title>Courier-imap</title> |
| 215 | <section> |
218 | <section> |
| 216 | <body> |
219 | <body> |
| 217 | |
220 | |
| 218 | <pre caption="Install courier-imap"> |
221 | <pre caption="Install courier-imap and courier-authlib"> |
| 219 | # <i>emerge courier-imap</i> |
222 | # <i>emerge courier-imap courier-authlib</i> |
| 220 | </pre> |
223 | </pre> |
| 221 | |
224 | |
| 222 | <pre caption="Courier-imap configuration"> |
225 | <pre caption="Courier-imap configuration"> |
| 223 | # <i>cd /etc/courier-imap</i> |
226 | # <i>cd /etc/courier-imap</i> |
| 224 | <comment>(If you want to use the ssl capabilities of courier-imap or pop3, |
227 | <comment>(If you want to use the ssl capabilities of courier-imap or pop3, |
| 225 | you'll need to create certs for this purpose. |
228 | you'll need to create certs for this purpose. |
| 226 | This step is recommended. If you do not want to use ssl, skip this step.)</comment> |
229 | This step is recommended. If you do not want to use ssl, skip this step.)</comment> |
| 227 | |
230 | |
| 228 | # <i>nano -w pop3d.cnf</i> |
231 | # <i>nano -w pop3d.cnf</i> |
| 229 | # <i>nano -w imapd.cnf</i> |
232 | # <i>nano -w imapd.cnf</i> |
| 230 | <comment>(Change the C, ST, L, CN, and email parameters to match your server.)</comment> |
233 | <comment>(Change the C, ST, L, CN, and email parameters to match your server.)</comment> |
| 231 | |
234 | |
| 232 | # <i>mkpop3dcert</i> |
235 | # <i>mkpop3dcert</i> |
| 233 | # <i>mkimapdcert</i> |
236 | # <i>mkimapdcert</i> |
| 234 | </pre> |
237 | </pre> |
| … | |
… | |
| 247 | running. Again, please verify that what we've installed already works before |
250 | running. Again, please verify that what we've installed already works before |
| 248 | progressing. |
251 | progressing. |
| 249 | </p> |
252 | </p> |
| 250 | |
253 | |
| 251 | </body> |
254 | </body> |
| 252 | </section> |
255 | </section> |
| 253 | </chapter> |
256 | </chapter> |
| 254 | |
257 | |
| 255 | <chapter> |
258 | <chapter> |
| 256 | <title>Cyrus-sasl</title> |
259 | <title>Cyrus-sasl</title> |
| 257 | <section> |
260 | <section> |
| 258 | <body> |
261 | <body> |
| 259 | |
262 | |
| 260 | <p> |
263 | <p> |
| 261 | Next we're going to install cyrus-sasl. Sasl is going to play the role of |
264 | Next we're going to install cyrus-sasl. Sasl is going to play the role of |
| 262 | actually passing your auth variables to pam, which will in turn pass that |
265 | actually passing your auth variables to courier-auth, which will in turn pass that |
| 263 | information to mysql for authentication of smtp users. For this howto, we'll |
266 | information to mysql for authentication of smtp users. For this howto, we'll |
| 264 | not even try to verify that sasl is working until mysql is set up and contains |
267 | not even try to verify that sasl is working until mysql is set up and contains |
| 265 | a test user. Which is fine since we'll be authenticating against mysql in the |
268 | a test user. Which is fine since we'll be authenticating against mysql in the |
| 266 | end anyway. |
269 | end anyway. |
| 267 | </p> |
270 | </p> |
| 268 | |
271 | |
| 269 | <pre caption="Configuring and installing the cyrus-sasl ebuild"> |
272 | <pre caption="Configuring and installing the cyrus-sasl ebuild"> |
| 270 | # <i>emerge cyrus-sasl</i> |
273 | # <i>emerge cyrus-sasl</i> |
| 271 | </pre> |
274 | </pre> |
| 272 | |
275 | |
| 273 | <p> |
276 | <p> |
| 274 | Next, edit <path>/etc/sasl2/smtpd.conf</path>. |
277 | Next, edit <path>/etc/sasl2/smtpd.conf</path>. |
| 275 | </p> |
278 | </p> |
| 276 | |
279 | |
| 277 | <pre caption="Starting sasl"> |
280 | <pre caption="Starting sasl"> |
| 278 | # <i>nano -w /etc/sasl2/smtpd.conf</i> |
281 | # <i>nano -w /etc/sasl2/smtpd.conf</i> |
| 279 | mech_list: PLAIN LOGIN |
282 | mech_list: PLAIN LOGIN |
| 280 | pwcheck_method: saslauthd |
283 | pwcheck_method: saslauthd |
| 281 | # <i>nano -w /etc/conf.d/saslauthd</i> |
284 | # <i>nano -w /etc/conf.d/saslauthd</i> |
| 282 | SASLAUTHD_OPTS="${SASLAUTH_MECH} -a pam -r" |
285 | SASLAUTHD_OPTS="${SASLAUTH_MECH} -a rimap -r" |
|
|
286 | SASLAUTHD_OPTS="${SASLAUTHD_OPTS} -O localhost" |
| 283 | # <i>/etc/init.d/saslauthd start</i> |
287 | # <i>/etc/init.d/saslauthd start</i> |
| 284 | </pre> |
288 | </pre> |
| 285 | |
289 | |
| 286 | </body> |
290 | </body> |
| 287 | </section> |
291 | </section> |
| 288 | </chapter> |
292 | </chapter> |
| 289 | |
293 | |
| 290 | <chapter> |
294 | <chapter> |
| 291 | <title>SSL Certs for Postfix and Apache</title> |
295 | <title>SSL Certs for Postfix and Apache</title> |
| 292 | <section> |
296 | <section> |
| 293 | <body> |
297 | <body> |
| 294 | |
298 | |
| 295 | <p> |
299 | <p> |
| 296 | Next we're going to make a set of ssl certificates for postfix and apache. |
300 | Next we're going to make a set of ssl certificates for postfix and apache. |
| 297 | </p> |
301 | </p> |
| … | |
… | |
| 638 | </section> |
642 | </section> |
| 639 | </chapter> |
643 | </chapter> |
| 640 | |
644 | |
| 641 | <chapter> |
645 | <chapter> |
| 642 | <title>Configuring MySQL Authentication and vhosts</title> |
646 | <title>Configuring MySQL Authentication and vhosts</title> |
| 643 | <section> |
647 | <section> |
| 644 | <body> |
648 | <body> |
| 645 | |
649 | |
| 646 | <p> |
650 | <p> |
| 647 | Next we'll reconfigure our authentication to use the mailsql database in |
651 | Next we'll reconfigure our authentication to use the mailsql database in |
| 648 | courier-imap and postfix. In all of the following examples, replace |
652 | courier-imap and postfix. In all of the following examples, replace |
| 649 | <c>$password</c> with the password you set for the mailsql mysql user. |
653 | <c>$password</c> with the password you set for the mailsql mysql user. |
| 650 | </p> |
654 | </p> |
| 651 | |
655 | |
| 652 | <pre caption="Configuring authentication"> |
656 | <pre caption="Configuring authentication"> |
| 653 | # <i>emerge pam_mysql</i> |
|
|
| 654 | # <i>nano -w /etc/pam.d/smtp</i> |
|
|
| 655 | <comment>(Comment out the existing auth lines and add the following as shown.)</comment> |
|
|
| 656 | |
|
|
| 657 | #auth required /lib/security/pam_stack.so service=system-auth |
|
|
| 658 | #account required /lib/security/pam_stack.so service=system-auth |
|
|
| 659 | |
|
|
| 660 | auth optional pam_mysql.so host=localhost db=mailsql user=mailsql \ |
|
|
| 661 | passwd=$password table=users usercolumn=email passwdcolumn=clear crypt=0 |
|
|
| 662 | account required pam_mysql.so host=localhost db=mailsql user=mailsql \ |
|
|
| 663 | passwd=$password table=users usercolumn=email passwdcolumn=clear crypt=0 |
|
|
| 664 | |
|
|
| 665 | </pre> |
|
|
| 666 | |
|
|
| 667 | <p> |
|
|
| 668 | Next, we need to edit courier's authentication config's. |
|
|
| 669 | </p> |
|
|
| 670 | |
|
|
| 671 | <pre caption="Configuring authentication"> |
|
|
| 672 | # <i>nano -w /etc/courier-imap/authdaemonrc</i> |
657 | # <i>nano -w /etc/courier/authlib/authdaemonrc</i> |
| 673 | authmodulelist="authmysql authpam" |
658 | authmodulelist="authmysql authpam" |
| 674 | |
659 | |
| 675 | # <i>nano -w /etc/courier-imap/authdaemond.conf</i> |
|
|
| 676 | AUTHDAEMOND="authdaemond.mysql" |
|
|
| 677 | |
|
|
| 678 | # <i>nano -w /etc/courier-imap/authmysqlrc</i> |
660 | # <i>nano -w /etc/courier/authlib/authmysqlrc</i> |
| 679 | MYSQL_SERVER localhost |
661 | MYSQL_SERVER localhost |
| 680 | MYSQL_USERNAME mailsql |
662 | MYSQL_USERNAME mailsql |
| 681 | MYSQL_PASSWORD $password |
663 | MYSQL_PASSWORD $password |
| 682 | MYSQL_DATABASE mailsql |
664 | MYSQL_DATABASE mailsql |
| 683 | MYSQL_USER_TABLE users |
665 | MYSQL_USER_TABLE users |
| 684 | <comment>(Make sure the following line is commented out since we're storing plaintext.)</comment> |
666 | <comment>(Make sure the following line is commented out since we're storing plaintext.)</comment> |
| 685 | #MYSQL_CRYPT_PWFIELD crypt |
667 | #MYSQL_CRYPT_PWFIELD crypt |
| 686 | MYSQL_CLEAR_PWFIELD clear |
668 | MYSQL_CLEAR_PWFIELD clear |
| 687 | MYSQL_UID_FIELD uid |
669 | MYSQL_UID_FIELD uid |
| 688 | MYSQL_GID_FIELD gid |
670 | MYSQL_GID_FIELD gid |
| 689 | MYSQL_LOGIN_FIELD email |
671 | MYSQL_LOGIN_FIELD email |
| 690 | MYSQL_HOME_FIELD homedir |
672 | MYSQL_HOME_FIELD homedir |
| 691 | MYSQL_NAME_FIELD name |
673 | MYSQL_NAME_FIELD name |
| 692 | MYSQL_MAILDIR_FIELD maildir |
674 | MYSQL_MAILDIR_FIELD maildir |
| 693 | |
675 | |