| 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 $ --> |
|
|
| 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> |
| … | |
… | |
| 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> |
|
|
20 | <author title="Editor"> |
|
|
21 | <mail link="swift@gentoo.org">Sven Vermeulen</mail> |
|
|
22 | </author> |
| 17 | |
23 | |
| 18 | <abstract> |
24 | <abstract> |
| 19 | This document details how to create a virtual mailhosting system based upon |
25 | This document details how to create a virtual mailhosting system based upon |
| 20 | postfix, mysql, courier-imap, and cyrus-sasl. |
26 | postfix, mysql, courier-imap, and cyrus-sasl. |
| 21 | </abstract> |
27 | </abstract> |
| 22 | |
28 | |
| 23 | <version>1.0.21</version> |
29 | <version>2</version> |
| 24 | <date>2005-05-23</date> |
30 | <date>2010-10-13</date> |
| 25 | |
|
|
| 26 | <!-- |
|
|
| 27 | Contents |
|
|
| 28 | |
|
|
| 29 | I. Introduction |
|
|
| 30 | II. Postfix Basics |
|
|
| 31 | III. Courier-imap |
|
|
| 32 | IV. Cyrus-sasl |
|
|
| 33 | V. SSL Certificates for Postfix and Apache |
|
|
| 34 | VI. Adding SSL and SASL support to Postfix |
|
|
| 35 | VII. MySQL |
|
|
| 36 | VIII. Apache and phpMyAdmin |
|
|
| 37 | IX. The vmail user |
|
|
| 38 | X. Configuring MySQL Authentication and vhosts |
|
|
| 39 | XI. Squirrelmail |
|
|
| 40 | XII. Mailman |
|
|
| 41 | XIII. Content Filtering and Anti-Virus |
|
|
| 42 | XIV. Wrap Up |
|
|
| 43 | XV. Troubleshooting |
|
|
| 44 | --> |
|
|
| 45 | |
31 | |
| 46 | <chapter> |
32 | <chapter> |
| 47 | <title>Introduction</title> |
33 | <title>Introduction</title> |
| 48 | <section> |
34 | <section> |
| 49 | <body> |
35 | <body> |
| 50 | |
36 | |
| 51 | <p> |
37 | <p> |
| 52 | For most gentoo users, a simple mail client and fetchmail will do. However, if |
38 | For most Gentoo users, a simple mail client and fetchmail will do. However, if |
| 53 | you're hosting a domain with your system, you'll need a full blown MTA (Mail |
39 | you're hosting a domain with your system, you'll need a full blown MTA (Mail |
| 54 | Transfer Agent). And if you're hosting multiple domains, then you'll definitely |
40 | Transfer Agent). And if you're hosting multiple domains, then you'll definitely |
| 55 | need something more robust to handle all of the email for your users. This |
41 | need something more robust to handle all of the email for your users. This |
| 56 | system was designed to be an elegant solution to that problem. |
42 | system was designed to be an elegant solution to that problem. |
| 57 | </p> |
43 | </p> |
| … | |
… | |
| 82 | needs. Consider investigating <uri>http://www.qmail.org/</uri> and |
68 | needs. Consider investigating <uri>http://www.qmail.org/</uri> and |
| 83 | <uri>http://www.exim.org/</uri> to explore your options. |
69 | <uri>http://www.exim.org/</uri> to explore your options. |
| 84 | </p> |
70 | </p> |
| 85 | |
71 | |
| 86 | <p> |
72 | <p> |
| 87 | The following packages are used in this setup: apache, courier-imap, pam_mysql, |
73 | The following packages are used in this setup: apache, courier-imap, |
| 88 | postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, php, and |
74 | courier-authlib postfix, mod_php, phpmyadmin, squirrelmail, cyrus-sasl, mysql, |
| 89 | mailman. |
75 | php, and mailman. |
| 90 | </p> |
76 | </p> |
| 91 | |
77 | |
| 92 | <p> |
78 | <p> |
| 93 | Make sure to turn on the following USE variables in <path>/etc/make.conf</path> |
79 | 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 |
80 | before compiling the packages: <c>USE="mysql imap libwww maildir |
| 95 | sasl ssl"</c>. Otherwise you will most likely have to recompile things to |
81 | 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 |
82 | 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. |
83 | turn off any other mail and network variables, like ipv6. |
| 98 | </p> |
84 | </p> |
| 99 | |
|
|
| 100 | <impo> |
|
|
| 101 | 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 |
|
|
| 103 | 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 |
|
|
| 105 | run into issues with this. |
|
|
| 106 | </impo> |
|
|
| 107 | |
|
|
| 108 | <impo> |
|
|
| 109 | This document uses apache-1.3.x. Apache-2 has been marked stable in portage. |
|
|
| 110 | However there are still a number of issues with php integration. Until php |
|
|
| 111 | support in apache-2.0.x is marked stable, this guide will continue to use the |
|
|
| 112 | 1.3.x version. |
|
|
| 113 | </impo> |
|
|
| 114 | |
85 | |
| 115 | <impo> |
86 | <impo> |
| 116 | You need a domain name to run a public mail server, or at least an MX record |
87 | You need a domain name to run a public mail server, or at least an MX record |
| 117 | for a domain. Ideally you would have control of at least two domains to take |
88 | for a domain. Ideally you would have control of at least two domains to take |
| 118 | advantage of your new virtual domain functionality. |
89 | advantage of your new virtual domain functionality. |
| 119 | </impo> |
90 | </impo> |
| 120 | |
91 | |
| 121 | <impo> |
92 | <impo> |
| 122 | Make sure <path>/etc/hostname</path> is set to the right hostname for your mail |
93 | Make sure <path>/etc/conf.d/hostname</path> is set to the right hostname for |
| 123 | server. Verify your hostname is set correctly with <c>hostname</c>. Also |
94 | your mail server. You can apply any changes you make to this file by running |
| 124 | verify that there are no conflicting entries in <path>/etc/hosts</path>. |
95 | <c>/etc/init.d/hostname restart</c>. Verify your hostname is set correctly with |
|
|
96 | <c>hostname</c>. Also verify that there are no conflicting entries in |
|
|
97 | <path>/etc/hosts</path>. |
| 125 | </impo> |
98 | </impo> |
| 126 | |
99 | |
| 127 | <note> |
100 | <note> |
| 128 | It is recommended that you read this entire document and familiarize yourself |
101 | It is recommended that you read this entire document and familiarize yourself |
| 129 | with all the steps before attempting the install. If you run into problems with |
102 | with all the steps before attempting the install. If you run into problems with |
| … | |
… | |
| 146 | # <i>emerge postfix</i> |
119 | # <i>emerge postfix</i> |
| 147 | </pre> |
120 | </pre> |
| 148 | |
121 | |
| 149 | <warn> |
122 | <warn> |
| 150 | Verify that you have not installed any other MTA, such as ssmtp, exim, or |
123 | Verify that you have not installed any other MTA, such as ssmtp, exim, or |
| 151 | qmail, or you will surely have BIG problems. |
124 | netqmail, or you will surely have BIG problems. |
| 152 | </warn> |
125 | </warn> |
| 153 | |
126 | |
| 154 | <p> |
127 | <p> |
| 155 | After postfix is installed, it's time to configure it. Change the following |
128 | After postfix is installed, it's time to configure it. Change the following |
| 156 | options in <path>/etc/postfix/main.cf</path>: |
129 | options in <path>/etc/postfix/main.cf</path>. Remember to replace |
|
|
130 | <c>$variables</c> with your own names. |
| 157 | </p> |
131 | </p> |
| 158 | |
132 | |
| 159 | <pre caption="/etc/postfix/main.cf"> |
133 | <pre caption="/etc/postfix/main.cf"> |
| 160 | myhostname = $host.domain.name |
134 | myhostname = $host.domain.name |
| 161 | mydomain = $domain.name |
135 | mydomain = $domain.name |
| … | |
… | |
| 188 | |
162 | |
| 189 | <pre caption="Starting postfix for the first time"> |
163 | <pre caption="Starting postfix for the first time"> |
| 190 | # <i>/usr/bin/newaliases</i> |
164 | # <i>/usr/bin/newaliases</i> |
| 191 | <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 |
| 192 | when you update or install aliases.)</comment> |
166 | when you update or install aliases.)</comment> |
| 193 | |
167 | |
| 194 | # <i>/etc/init.d/postfix start</i> |
168 | # <i>/etc/init.d/postfix start</i> |
| 195 | </pre> |
169 | </pre> |
| 196 | |
170 | |
| 197 | <p> |
171 | <p> |
| 198 | Now that postfix is running, fire up your favorite console mail client and send |
172 | Now that postfix is running, fire up your favorite console mail client and send |
| … | |
… | |
| 213 | <chapter> |
187 | <chapter> |
| 214 | <title>Courier-imap</title> |
188 | <title>Courier-imap</title> |
| 215 | <section> |
189 | <section> |
| 216 | <body> |
190 | <body> |
| 217 | |
191 | |
| 218 | <pre caption="Install courier-imap"> |
192 | <pre caption="Install courier-imap and courier-authlib"> |
| 219 | # <i>emerge courier-imap</i> |
193 | # <i>emerge courier-imap courier-authlib</i> |
| 220 | </pre> |
194 | </pre> |
| 221 | |
195 | |
| 222 | <pre caption="Courier-imap configuration"> |
196 | <pre caption="Courier-imap configuration"> |
| 223 | # <i>cd /etc/courier-imap</i> |
197 | # <i>cd /etc/courier-imap</i> |
| 224 | <comment>(If you want to use the ssl capabilities of courier-imap or pop3, |
198 | <comment>(If you want to use the ssl capabilities of courier-imap or pop3, |
| … | |
… | |
| 240 | # <i>/etc/init.d/courier-pop3d-ssl start</i> |
214 | # <i>/etc/init.d/courier-pop3d-ssl start</i> |
| 241 | </pre> |
215 | </pre> |
| 242 | |
216 | |
| 243 | <p> |
217 | <p> |
| 244 | Start up your favorite mail client and verify that all connections you've |
218 | Start up your favorite mail client and verify that all connections you've |
| 245 | started work for receiving and sending mail. Now that the basics work, we're |
219 | started work for receiving and sending mail. Of course, you won't be able to log |
| 246 | going to do a whole bunch of stuff at once to get the rest of the system |
220 | on to any of the services because authentication hasn't been configured yet, but |
| 247 | running. Again, please verify that what we've installed already works before |
221 | it is wise to check if the connections themselves work or not. |
| 248 | progressing. |
222 | </p> |
|
|
223 | |
|
|
224 | <p> |
|
|
225 | Now that the basics work, we're going to do a whole bunch of stuff at once to |
|
|
226 | get the rest of the system running. Again, please verify that what we've |
|
|
227 | installed already works before progressing. |
| 249 | </p> |
228 | </p> |
| 250 | |
229 | |
| 251 | </body> |
230 | </body> |
| 252 | </section> |
231 | </section> |
| 253 | </chapter> |
232 | </chapter> |
| … | |
… | |
| 257 | <section> |
236 | <section> |
| 258 | <body> |
237 | <body> |
| 259 | |
238 | |
| 260 | <p> |
239 | <p> |
| 261 | Next we're going to install cyrus-sasl. Sasl is going to play the role of |
240 | 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 |
241 | actually passing your auth variables to courier-auth, which will in turn pass |
| 263 | information to mysql for authentication of smtp users. For this howto, we'll |
242 | that information to mysql for authentication of smtp users. For this howto, |
| 264 | not even try to verify that sasl is working until mysql is set up and contains |
243 | we'll not even try to verify that sasl is working until mysql is set up and |
| 265 | a test user. Which is fine since we'll be authenticating against mysql in the |
244 | contains a test user. Which is fine since we'll be authenticating against |
| 266 | end anyway. |
245 | mysql in the end anyway. |
| 267 | </p> |
246 | </p> |
| 268 | |
247 | |
| 269 | <pre caption="Configuring and installing the cyrus-sasl ebuild"> |
248 | <pre caption="Configuring and installing the cyrus-sasl ebuild"> |
| 270 | # <i>emerge cyrus-sasl</i> |
249 | # <i>emerge cyrus-sasl</i> |
| 271 | </pre> |
250 | </pre> |
| … | |
… | |
| 277 | <pre caption="Starting sasl"> |
256 | <pre caption="Starting sasl"> |
| 278 | # <i>nano -w /etc/sasl2/smtpd.conf</i> |
257 | # <i>nano -w /etc/sasl2/smtpd.conf</i> |
| 279 | mech_list: PLAIN LOGIN |
258 | mech_list: PLAIN LOGIN |
| 280 | pwcheck_method: saslauthd |
259 | pwcheck_method: saslauthd |
| 281 | # <i>nano -w /etc/conf.d/saslauthd</i> |
260 | # <i>nano -w /etc/conf.d/saslauthd</i> |
| 282 | SASLAUTHD_OPTS="${SASLAUTH_MECH} -a pam -r" |
261 | SASLAUTHD_OPTS="${SASLAUTH_MECH} -a rimap -r" |
|
|
262 | SASLAUTHD_OPTS="${SASLAUTHD_OPTS} -O localhost" |
| 283 | # <i>/etc/init.d/saslauthd start</i> |
263 | # <i>/etc/init.d/saslauthd start</i> |
| 284 | </pre> |
264 | </pre> |
| 285 | |
265 | |
| 286 | </body> |
266 | </body> |
| 287 | </section> |
267 | </section> |
| … | |
… | |
| 309 | emailAddress_default. |
289 | emailAddress_default. |
| 310 | |
290 | |
| 311 | <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> |
| 312 | |
292 | |
| 313 | # <i>cd misc</i> |
293 | # <i>cd misc</i> |
| 314 | # <i>nano -w CA.pl</i> |
294 | # <i>./CA.pl -newreq-nodes</i> |
| 315 | <comment>(We need to add -nodes to the # create a certificate and |
|
|
| 316 | #create a certificate request code in order to let our new ssl |
|
|
| 317 | certs be loaded without a password. Otherwise when you |
|
|
| 318 | reboot your ssl certs will not be available.)</comment> |
|
|
| 319 | |
|
|
| 320 | # create a certificate |
|
|
| 321 | system ("$REQ -new -nodes -x509 -keyout newreq.pem -out newreq.pem $DAYS"); |
|
|
| 322 | |
|
|
| 323 | # create a certificate request |
|
|
| 324 | system ("$REQ -new -nodes -keyout newreq.pem -out newreq.pem $DAYS"); |
|
|
| 325 | |
|
|
| 326 | # <i>./CA.pl -newca</i> |
295 | # <i>./CA.pl -newca</i> |
| 327 | # <i>./CA.pl -newreq</i> |
|
|
| 328 | # <i>./CA.pl -sign</i> |
296 | # <i>./CA.pl -sign</i> |
| 329 | # <i>cp newcert.pem /etc/postfix</i> |
297 | # <i>cp newcert.pem /etc/postfix</i> |
| 330 | # <i>cp newreq.pem /etc/postfix</i> |
298 | # <i>cp newkey.pem /etc/postfix</i> |
| 331 | # <i>cp demoCA/cacert.pem /etc/postfix</i> |
299 | # <i>cp demoCA/cacert.pem /etc/postfix</i> |
| 332 | <comment>(Now we do the same thing for apache.)</comment> |
300 | <comment>(Now we do the same thing for apache.)</comment> |
| 333 | |
301 | |
| 334 | # <i>openssl req -new > new.cert.csr</i> |
302 | # <i>openssl req -new > new.cert.csr</i> |
| 335 | # <i>openssl rsa -in privkey.pem -out new.cert.key</i> |
303 | # <i>openssl rsa -in privkey.pem -out new.cert.key</i> |
| … | |
… | |
| 368 | smtpd_sasl_local_domain appends a domain name to clients using |
336 | smtpd_sasl_local_domain appends a domain name to clients using |
| 369 | smtp-auth. Make sure it's blank or your user names will get |
337 | smtp-auth. Make sure it's blank or your user names will get |
| 370 | mangled by postfix and be unable to auth.)</comment> |
338 | mangled by postfix and be unable to auth.)</comment> |
| 371 | |
339 | |
| 372 | smtpd_recipient_restrictions = |
340 | smtpd_recipient_restrictions = |
| 373 | permit_sasl_authenticated, |
341 | permit_sasl_authenticated, |
| 374 | permit_mynetworks, |
342 | permit_mynetworks, |
| 375 | reject_unauth_destination |
343 | reject_unauth_destination |
| 376 | |
|
|
| 377 | |
344 | |
|
|
345 | <comment>(The next two options enable outgoing encryption.)</comment> |
|
|
346 | smtp_use_tls = yes |
|
|
347 | smtp_tls_note_starttls_offer = yes |
| 378 | smtpd_use_tls = yes |
348 | smtpd_use_tls = yes |
| 379 | #smtpd_tls_auth_only = yes |
349 | #smtpd_tls_auth_only = yes |
| 380 | smtpd_tls_key_file = /etc/postfix/newreq.pem |
350 | smtpd_tls_key_file = /etc/postfix/newkey.pem |
| 381 | smtpd_tls_cert_file = /etc/postfix/newcert.pem |
351 | smtpd_tls_cert_file = /etc/postfix/newcert.pem |
| 382 | smtpd_tls_CAfile = /etc/postfix/cacert.pem |
352 | smtpd_tls_CAfile = /etc/postfix/cacert.pem |
| 383 | smtpd_tls_loglevel = 3 |
353 | smtpd_tls_loglevel = 3 |
| 384 | smtpd_tls_received_header = yes |
354 | smtpd_tls_received_header = yes |
| 385 | smtpd_tls_session_cache_timeout = 3600s |
355 | smtpd_tls_session_cache_timeout = 3600s |
| … | |
… | |
| 391 | # <i>postfix reload</i> |
361 | # <i>postfix reload</i> |
| 392 | </pre> |
362 | </pre> |
| 393 | |
363 | |
| 394 | <p> |
364 | <p> |
| 395 | Now we're going to verify that the config's we added were picked up by postfix. |
365 | Now we're going to verify that the config's we added were picked up by postfix. |
|
|
366 | For 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>): |
| 396 | </p> |
369 | </p> |
| 397 | |
370 | |
| 398 | <pre caption="Verifying sasl and tls support"> |
371 | <pre caption="Verifying sasl and tls support"> |
| 399 | # <i>telnet localhost 25</i> |
372 | # <i>telnet localhost 25</i> |
| 400 | |
373 | |
| … | |
… | |
| 428 | </body> |
401 | </body> |
| 429 | </section> |
402 | </section> |
| 430 | </chapter> |
403 | </chapter> |
| 431 | |
404 | |
| 432 | <chapter> |
405 | <chapter> |
|
|
406 | <title>The vmail user</title> |
|
|
407 | <section> |
|
|
408 | <body> |
|
|
409 | |
|
|
410 | <p> |
|
|
411 | Before we set up our virtual mailhosting environment, we create a functional |
|
|
412 | user under which the virtual mailboxes will be hosted. For clarity's sake we |
|
|
413 | will 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> |
|
|
421 | So now you've set up the vmail account. You can create multiple accounts if you |
|
|
422 | want (to keep some structure in your set of virtual mail accounts). The user id, |
|
|
423 | group id and home dirs are referenced in the MySQL tables. |
|
|
424 | </p> |
|
|
425 | |
|
|
426 | <p> |
|
|
427 | Next to the user account we also need to create the location where the mailboxes |
|
|
428 | will 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> |
| 433 | <title>MySQL</title> |
442 | <title>MySQL</title> |
| 434 | <section> |
443 | <section> |
| 435 | <body> |
444 | <body> |
| 436 | |
445 | |
| 437 | <p> |
446 | <p> |
| … | |
… | |
| 443 | <pre caption="Installing and configuring MySQL"> |
452 | <pre caption="Installing and configuring MySQL"> |
| 444 | # <i>emerge mysql</i> |
453 | # <i>emerge mysql</i> |
| 445 | |
454 | |
| 446 | # <i>/usr/bin/mysql_install_db</i> |
455 | # <i>/usr/bin/mysql_install_db</i> |
| 447 | <comment>(After this command runs follow the onscreen directions |
456 | <comment>(After this command runs follow the onscreen directions |
| 448 | for adding a root password with mysql, |
457 | for adding a root password with mysql, otherwise your db will |
| 449 | not mysqladmin, otherwise your db will be wide open.)</comment> |
458 | be wide open.)</comment> |
| 450 | |
459 | |
| 451 | # <i>/etc/init.d/mysql start</i> |
460 | # <i>/etc/init.d/mysql start</i> |
| 452 | # <i>mysqladmin -u root -p create mailsql</i> |
461 | # <i>mysqladmin -u root -p create mailsql</i> |
| 453 | # <i>mysql -u root -p mailsql < genericmailsql.sql</i> |
462 | # <i>mysql -u root -p mailsql < genericmailsql.sql</i> |
| 454 | |
|
|
| 455 | # <i>mysql -u root -p mysql</i> |
463 | # <i>mysql -u root -p mysql</i> |
| 456 | mysql> <i>GRANT SELECT,INSERT,UPDATE,DELETE</i> |
464 | mysql> <i>GRANT SELECT,INSERT,UPDATE,DELETE</i> |
| 457 | -> <i>ON mailsql.*</i> |
465 | -> <i>ON mailsql.*</i> |
| 458 | -> <i>TO mailsql@localhost</i> |
466 | -> <i>TO mailsql@localhost</i> |
| 459 | -> <i>IDENTIFIED BY '$password';</i> |
467 | -> <i>IDENTIFIED BY '$password';</i> |
|
|
468 | Query OK, 0 rows affected (0.02 sec) |
| 460 | |
469 | |
| 461 | -> <i>quit</i> |
470 | mysql> <i>FLUSH PRIVILEGES;</i> |
|
|
471 | Query OK, 0 rows affected (0.00 sec) |
|
|
472 | |
|
|
473 | mysql> <i>quit</i> |
| 462 | <comment>(Verify that the new mailsql user can connect to the mysql server.)</comment> |
474 | <comment>(Verify that the new mailsql user can connect to the mysql server.)</comment> |
| 463 | |
475 | |
| 464 | # <i>mysql -u mailsql -p mailsql</i> |
476 | # <i>mysql -u mailsql -p mailsql</i> |
| 465 | </pre> |
477 | </pre> |
| 466 | |
478 | |
| … | |
… | |
| 479 | <li>users - all user account information</li> |
491 | <li>users - all user account information</li> |
| 480 | <li>virtual - virtual domain email alias maps</li> |
492 | <li>virtual - virtual domain email alias maps</li> |
| 481 | </ul> |
493 | </ul> |
| 482 | |
494 | |
| 483 | <pre caption="alias table sample"> |
495 | <pre caption="alias table sample"> |
| 484 | id alias destination |
496 | id alias destination |
| 485 | 1 root foo@bar.com |
497 | 1 root foo@bar.com |
| 486 | 2 postmaster foo@bar.com |
498 | 2 postmaster foo@bar.com |
| 487 | </pre> |
499 | </pre> |
| 488 | |
500 | |
| 489 | <pre caption="user table sample"> |
501 | <pre caption="user table sample"> |
| 490 | <comment>(Line wrapped for clarity.)</comment> |
502 | <comment>(Line wrapped for clarity.)</comment> |
| 491 | id email clear name uid gid homedir \ |
503 | id email clear name uid gid homedir \ |
| 492 | maildir quota postfix |
504 | maildir quota postfix |
| 493 | 10 foo@virt-bar.org $password realname virtid virtid /home/vmail \ |
505 | 10 foo@virt-domain.com $password realname virtid virtid /home/vmail \ |
| 494 | /home/vmail/virt-bar.org/foo/.maildir/ y |
506 | /home/vmail/virt-domain.com/foo/.maildir/ y |
| 495 | 13 foo@bar.com $password realname localid localid /home/foo \ |
507 | 13 foo@bar.com $password realname localid localid /home/foo \ |
| 496 | /home/foo/.maildir/ y |
508 | /home/foo/.maildir/ y |
| 497 | </pre> |
509 | </pre> |
| 498 | |
510 | |
| 499 | <p> |
511 | <p> |
| 500 | The values of the <c>virtid</c> uid and gid should be those of the <c>vmail</c> |
512 | The values of the <c>virtid</c> uid and gid should be those of the <c>vmail</c> |
| 501 | user and group. |
513 | user and group. |
| 502 | </p> |
514 | </p> |
| 503 | |
515 | |
| 504 | <pre caption="transport table sample"> |
516 | <pre caption="transport table sample"> |
| 505 | id domain destination |
517 | id domain destination |
| 506 | 1 bar.com local: |
518 | 1 bar.com local: |
| 507 | 2 virt-bar.org virtual: |
519 | 2 virt-domain.com virtual: |
| 508 | </pre> |
520 | </pre> |
| 509 | |
521 | |
| 510 | <pre caption="virtual table sample"> |
522 | <pre caption="virtual table sample"> |
| 511 | id email destination |
523 | id email destination |
| 512 | 3 root@virt-bar.org other@email.address |
524 | 3 root@virt-domain.com other@email.address |
| 513 | </pre> |
525 | </pre> |
| 514 | |
526 | |
| 515 | </body> |
527 | </body> |
| 516 | </section> |
528 | </section> |
| 517 | </chapter> |
529 | </chapter> |
| … | |
… | |
| 525 | Next we'll set up apache and add an interface to interact with the database |
537 | Next we'll set up apache and add an interface to interact with the database |
| 526 | more easily. |
538 | more easily. |
| 527 | </p> |
539 | </p> |
| 528 | |
540 | |
| 529 | <pre caption="Setting up apache and phpmyadmin"> |
541 | <pre caption="Setting up apache and phpmyadmin"> |
| 530 | # <i>emerge apache mod_php phpmyadmin</i> |
542 | # <i>emerge apache phpmyadmin</i> |
| 531 | </pre> |
543 | </pre> |
| 532 | |
544 | |
| 533 | <p> |
545 | <p> |
| 534 | There are plenty of guides out there about how to set up apache with php. Like |
546 | There are plenty of guides out there about how to set up apache with php, |
| 535 | this one: <uri>http://www.linuxguruz.org/z.php?id=31</uri>. There are also |
547 | including guides provided by the <uri link="/proj/en/php/">Gentoo PHP |
|
|
548 | Project</uri>. There are also numerous posts on |
| 536 | numerous 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 |
| 537 | problems with the installation (search for 'apache php'). So, that said, I'm |
550 | installation. So, that said, we're not going to cover it here. Set up the |
| 538 | not going to cover it here. Set up the apache and php installs, then continue |
551 | apache and php installs, then continue with this howto. Now, a word for the |
| 539 | with this howto. Now, a word for the wise: .htaccess the directory that you put |
552 | wise: .htaccess the directory that you put phpmyadmin in. If you do not do this, |
| 540 | phpmyadmin in. If you do not do this, search engine spiders will come along and |
553 | search engine spiders will come along and index the page which in turn will mean |
| 541 | index the page which in turn will mean that anyone will be able to find your |
554 | that anyone will be able to find your phpmyadmin page via google and in turn be |
| 542 | phpmyadmin page via google and in turn be able to come change your database |
555 | able to come change your database however they want which is <e>BAD!</e> There |
| 543 | however they want which is <e>BAD!</e> There are many howtos on this |
556 | are many howtos on this including: |
| 544 | including: <uri>http://www.csoft.net/docs/micro/htaccess.html.en</uri>. |
557 | <uri>http://www.csoft.net/docs/micro/htaccess.html.en</uri>. |
| 545 | </p> |
558 | </p> |
| 546 | |
559 | |
| 547 | <p> |
560 | <p> |
| 548 | Now we're going to install the Apache certificates we made previously. The |
561 | Now we're going to install the Apache certificates we made previously. The |
| 549 | Apache-SSL directives that you need to use the resulting cert are: |
562 | Apache-SSL directives that you need to use the resulting cert are: |
| … | |
… | |
| 553 | <li>SSLCertificateFile /path/to/certs/new.cert.cert</li> |
566 | <li>SSLCertificateFile /path/to/certs/new.cert.cert</li> |
| 554 | <li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li> |
567 | <li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li> |
| 555 | </ul> |
568 | </ul> |
| 556 | |
569 | |
| 557 | <pre caption="Install Apache SSL certificates"> |
570 | <pre caption="Install Apache SSL certificates"> |
| 558 | # <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> |
| 559 | # <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> |
| 560 | # <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> |
| 561 | |
578 | |
| 562 | <comment>(Change the following parameters)</comment> |
579 | <comment>(Change the following parameters)</comment> |
|
|
580 | NameVirtualHost host.domain.name:443 |
| 563 | |
581 | |
|
|
582 | <VirtualHost host.domain.name:443> |
| 564 | ServerName host.domain.name |
583 | ServerName host.domain.name |
| 565 | ServerAdmin your@email.address |
584 | ServerAdmin your@email.address |
|
|
585 | |
|
|
586 | DocumentRoot "/var/www/localhost/htdocs/phpmyadmin"; |
|
|
587 | <Directory "/var/www/localhost/htdocs/phpmyadmin"> |
|
|
588 | ... |
|
|
589 | </Directory> |
|
|
590 | |
| 566 | SSLCertificateFile /etc/apache/conf/ssl/new.cert.cert |
591 | SSLCertificateFile /etc/apache2/ssl/new.cert.cert |
| 567 | SSLCertificateKeyFile /etc/apache/conf/ssl/new.cert.key |
592 | SSLCertificateKeyFile /etc/apache2/ssl/new.cert.key |
|
|
593 | SSLEngine on |
|
|
594 | ... |
|
|
595 | </VirtualHost> |
| 568 | |
596 | |
|
|
597 | # <i>nano -w /etc/conf.d/apache2</i> |
|
|
598 | <comment>(Add -D SSL -D PHP5 to the APACHE2_OPTS)</comment> |
|
|
599 | |
| 569 | # <i>/etc/init.d/apache restart</i> |
600 | # <i>/etc/init.d/apache2 restart</i> |
| 570 | </pre> |
601 | </pre> |
| 571 | |
|
|
| 572 | <note> |
|
|
| 573 | If you have an existing apache install, you'll likely have to perform a full |
|
|
| 574 | server reboot to install your new certificates. Check your logs to verify |
|
|
| 575 | apache restarted successfully. |
|
|
| 576 | </note> |
|
|
| 577 | |
602 | |
| 578 | <p> |
603 | <p> |
| 579 | Next, configure phpMyAdmin. |
604 | Next, configure phpMyAdmin. |
| 580 | </p> |
605 | </p> |
| 581 | |
606 | |
| 582 | <pre caption="Configuring phpMyAdmin"> |
607 | <pre caption="Configuring phpMyAdmin"> |
| 583 | # <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> |
| 584 | <comment>(Change the following parameters.)</comment> |
611 | <comment>(Change the following parameters.)</comment> |
|
|
612 | $cfg['blowfish_secret'] = 'someverysecretpassphraze'; |
| 585 | |
613 | |
| 586 | $cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname |
614 | $cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname |
| 587 | $cfg['Servers'][$i]['controluser'] = 'mailsql'; // MySQL control user settings |
615 | $cfg['Servers'][$i]['controluser'] = 'mailsql'; // MySQL control user settings |
| 588 | // (this user must have read-only |
616 | // (this user must have read-only |
| 589 | $cfg['Servers'][$i]['controlpass'] = '$password'; // access to the "mysql/user" |
617 | $cfg['Servers'][$i]['controlpass'] = '$password'; // access to the "mysql/user" |
| … | |
… | |
| 596 | Now enter the phpmyadmin page and browse the tables. You'll want to add in your |
624 | Now enter the phpmyadmin page and browse the tables. You'll want to add in your |
| 597 | local aliases, edit your user table to add a test user, and change your |
625 | local aliases, edit your user table to add a test user, and change your |
| 598 | transport table to add information about your domains. The default values |
626 | transport table to add information about your domains. The default values |
| 599 | supplied with the dumpfile should be a sufficient guide to what values need to |
627 | supplied with the dumpfile should be a sufficient guide to what values need to |
| 600 | go where. Make sure that if you put information in the database that it is |
628 | go where. Make sure that if you put information in the database that it is |
| 601 | accurate. For instance, make sure the local users home dir exists and that the |
629 | accurate. For instance, make sure the local user's home dir exists and that the |
| 602 | correct uid/gid values are in place. The maildirs should be created |
630 | correct uid/gid values are in place. The maildirs should be created |
| 603 | automatically by postfix when the user receives their first email. So, in |
631 | automatically by postfix when the user receives their first email. So, in |
| 604 | general, it's a good idea to send a "Welcome" mail to a new user |
632 | general, it's a good idea to send a "Welcome" mail to a new user after you |
| 605 | after you setup their account to make sure the .maildir gets created. |
633 | setup their account to make sure the .maildir gets created. |
| 606 | </p> |
|
|
| 607 | |
|
|
| 608 | </body> |
|
|
| 609 | </section> |
|
|
| 610 | </chapter> |
|
|
| 611 | |
|
|
| 612 | <chapter> |
|
|
| 613 | <title>The vmail user</title> |
|
|
| 614 | <section> |
|
|
| 615 | <body> |
|
|
| 616 | |
|
|
| 617 | <p> |
|
|
| 618 | At this point you may be wondering what user and directory to use for virtual |
|
|
| 619 | mail users, and rightly so. Let's set that up. |
|
|
| 620 | </p> |
|
|
| 621 | |
|
|
| 622 | <pre caption="Adding the vmail user"> |
|
|
| 623 | # <i>adduser -d /home/vmail -s /bin/false vmail</i> |
|
|
| 624 | # <i>uid=`cat /etc/passwd | grep vmail | cut -f 3 -d :`</i> |
|
|
| 625 | # <i>groupadd -g $uid vmail</i> |
|
|
| 626 | # <i>mkdir /home/vmail</i> |
|
|
| 627 | # <i>chown vmail: /home/vmail</i> |
|
|
| 628 | </pre> |
|
|
| 629 | |
|
|
| 630 | <p> |
|
|
| 631 | So now when you're setting up vmail accounts, use the vmail uid, gid, and |
|
|
| 632 | homedir. When you're setting up local accounts, use that users uid, gid, and |
|
|
| 633 | homedir. We've been meaning to create a php admin page for this setup but |
|
|
| 634 | haven't gotten around to it yet, as phpmyadmin generally works fine for us. |
|
|
| 635 | </p> |
634 | </p> |
| 636 | |
635 | |
| 637 | </body> |
636 | </body> |
| 638 | </section> |
637 | </section> |
| 639 | </chapter> |
638 | </chapter> |
| … | |
… | |
| 648 | courier-imap and postfix. In all of the following examples, replace |
647 | 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. |
648 | <c>$password</c> with the password you set for the mailsql mysql user. |
| 650 | </p> |
649 | </p> |
| 651 | |
650 | |
| 652 | <pre caption="Configuring authentication"> |
651 | <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> |
652 | # <i>nano -w /etc/courier/authlib/authdaemonrc</i> |
| 673 | authmodulelist="authmysql authpam" |
653 | authmodulelist="authmysql authpam" |
| 674 | |
654 | |
| 675 | # <i>nano -w /etc/courier-imap/authdaemond.conf</i> |
|
|
| 676 | AUTHDAEMOND="authdaemond.mysql" |
|
|
| 677 | |
|
|
| 678 | # <i>nano -w /etc/courier-imap/authmysqlrc</i> |
655 | # <i>nano -w /etc/courier/authlib/authmysqlrc</i> |
| 679 | MYSQL_SERVER localhost |
656 | MYSQL_SERVER localhost |
| 680 | MYSQL_USERNAME mailsql |
657 | MYSQL_USERNAME mailsql |
| 681 | MYSQL_PASSWORD $password |
658 | MYSQL_PASSWORD $password |
| 682 | MYSQL_DATABASE mailsql |
659 | MYSQL_DATABASE mailsql |
| 683 | MYSQL_USER_TABLE users |
660 | MYSQL_USER_TABLE users |
| … | |
… | |
| 694 | # <i>/etc/init.d/courier-authlib restart</i> |
671 | # <i>/etc/init.d/courier-authlib restart</i> |
| 695 | # <i>/etc/init.d/saslauthd restart</i> |
672 | # <i>/etc/init.d/saslauthd restart</i> |
| 696 | </pre> |
673 | </pre> |
| 697 | |
674 | |
| 698 | <p> |
675 | <p> |
| 699 | We're almost there I promise! Next, set up the rest of the necessary config's |
676 | We're almost there, I promise! Next, set up the rest of the necessary configs |
| 700 | for postfix to interract with the database for all it's other transport needs. |
677 | for postfix to interract with the database for all its other transport needs. |
|
|
678 | Remember to replace each value with the name of your own user, user id, |
|
|
679 | password, alias, email address, and so on. |
| 701 | </p> |
680 | </p> |
| 702 | |
681 | |
| 703 | <pre caption="/etc/postfix/mysql-aliases.cf"> |
682 | <pre caption="/etc/postfix/mysql-aliases.cf"> |
| 704 | # <i>nano -w /etc/postfix/mysql-aliases.cf</i> |
683 | # <i>nano -w /etc/postfix/mysql-aliases.cf</i> |
| 705 | # mysql-aliases.cf |
684 | # mysql-aliases.cf |
| 706 | |
685 | |
| 707 | user = mailsql |
686 | user = mailsql |
| 708 | password = $password |
687 | password = $password |
| 709 | dbname = mailsql |
688 | dbname = mailsql |
| 710 | table = alias |
689 | table = alias |
| 711 | select_field = destination |
690 | select_field = destination |
| 712 | where_field = alias |
691 | where_field = alias |
| 713 | hosts = unix:/var/run/mysqld/mysqld.sock |
692 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 714 | </pre> |
693 | </pre> |
| 715 | |
694 | |
| 716 | <pre caption="/etc/postfix/mysql-relocated.cf"> |
695 | <pre caption="/etc/postfix/mysql-relocated.cf"> |
| 717 | # <i>nano -w /etc/postfix/mysql-relocated.cf</i> |
696 | # <i>nano -w /etc/postfix/mysql-relocated.cf</i> |
| 718 | # mysql-relocated.cf |
697 | # mysql-relocated.cf |
| 719 | |
698 | |
| 720 | user = mailsql |
699 | user = mailsql |
| 721 | password = $password |
700 | password = $password |
| 722 | dbname = mailsql |
701 | dbname = mailsql |
| 723 | table = relocated |
702 | table = relocated |
| 724 | select_field = destination |
703 | select_field = destination |
| 725 | where_field = email |
704 | where_field = email |
| 726 | hosts = unix:/var/run/mysqld/mysqld.sock |
705 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 727 | </pre> |
706 | </pre> |
| 728 | |
707 | |
| 729 | <pre caption="/etc/postfix/mysql-transport.cf (optional)"> |
708 | <pre caption="/etc/postfix/mysql-transport.cf (optional)"> |
| 730 | # <i>nano -w /etc/postfix/mysql-transport.cf</i> |
709 | # <i>nano -w /etc/postfix/mysql-transport.cf</i> |
| 731 | # mysql-transport.cf |
710 | # mysql-transport.cf |
| 732 | |
711 | |
| 733 | user = mailsql |
712 | user = mailsql |
| 734 | password = $password |
713 | password = $password |
| 735 | dbname = mailsql |
714 | dbname = mailsql |
| 736 | table = transport |
715 | table = transport |
| 737 | select_field = destination |
716 | select_field = destination |
| 738 | where_field = domain |
717 | where_field = domain |
| 739 | hosts = unix:/var/run/mysqld/mysqld.sock |
718 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 740 | </pre> |
719 | </pre> |
| 741 | |
720 | |
| 742 | <pre caption="/etc/postfix/mysql-virtual-gid.cf (optional)"> |
721 | <pre caption="/etc/postfix/mysql-virtual-gid.cf (optional)"> |
| 743 | # <i>nano -w /etc/postfix/mysql-virtual-gid.cf</i> |
722 | # <i>nano -w /etc/postfix/mysql-virtual-gid.cf</i> |
| 744 | #myql-virtual-gid.cf |
723 | # mysql-virtual-gid.cf |
| 745 | |
724 | |
| 746 | user = mailsql |
725 | user = mailsql |
| 747 | password = $password |
726 | password = $password |
| 748 | dbname = mailsql |
727 | dbname = mailsql |
| 749 | table = users |
728 | table = users |
| 750 | select_field = gid |
729 | select_field = gid |
| 751 | where_field = email |
730 | where_field = email |
| 752 | additional_conditions = and postfix = 'y' |
731 | additional_conditions = and postfix = 'y' |
| 753 | hosts = unix:/var/run/mysqld/mysqld.sock |
732 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 754 | </pre> |
733 | </pre> |
| 755 | |
734 | |
| 756 | <pre caption="/etc/postfix/mysql-virtual-maps.cf"> |
735 | <pre caption="/etc/postfix/mysql-virtual-maps.cf"> |
| 757 | # <i>nano -w /etc/postfix/mysql-virtual-maps.cf</i> |
736 | # <i>nano -w /etc/postfix/mysql-virtual-maps.cf</i> |
| 758 | #myql-virtual-maps.cf |
737 | # mysql-virtual-maps.cf |
| 759 | |
738 | |
| 760 | user = mailsql |
739 | user = mailsql |
| 761 | password = $password |
740 | password = $password |
| 762 | dbname = mailsql |
741 | dbname = mailsql |
| 763 | table = users |
742 | table = users |
| 764 | select_field = maildir |
743 | select_field = maildir |
| 765 | where_field = email |
744 | where_field = email |
| 766 | additional_conditions = and postfix = 'y' |
745 | additional_conditions = and postfix = 'y' |
| 767 | hosts = unix:/var/run/mysqld/mysqld.sock |
746 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 768 | </pre> |
747 | </pre> |
| 769 | |
748 | |
| 770 | <pre caption="/etc/postfix/mysql-virtual-uid.cf (optional)"> |
749 | <pre caption="/etc/postfix/mysql-virtual-uid.cf (optional)"> |
| … | |
… | |
| 774 | user = mailsql |
753 | user = mailsql |
| 775 | password = $password |
754 | password = $password |
| 776 | dbname = mailsql |
755 | dbname = mailsql |
| 777 | table = users |
756 | table = users |
| 778 | select_field = uid |
757 | select_field = uid |
| 779 | where_field = email |
758 | where_field = email |
| 780 | additional_conditions = and postfix = 'y' |
759 | additional_conditions = and postfix = 'y' |
| 781 | hosts = unix:/var/run/mysqld/mysqld.sock |
760 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 782 | </pre> |
761 | </pre> |
| 783 | |
762 | |
| 784 | <pre caption="/etc/postfix/mysql-virtual.cf"> |
763 | <pre caption="/etc/postfix/mysql-virtual.cf"> |
| 785 | # <i>nano -w /etc/postfix/mysql-virtual.cf</i> |
764 | # <i>nano -w /etc/postfix/mysql-virtual.cf</i> |
| 786 | # mysql-virtual.cf |
765 | # mysql-virtual.cf |
| 787 | |
766 | |
| 788 | user = mailsql |
767 | user = mailsql |
| 789 | password = $password |
768 | password = $password |
| 790 | dbname = mailsql |
769 | dbname = mailsql |
| 791 | table = virtual |
770 | table = virtual |
| 792 | select_field = destination |
771 | select_field = destination |
| 793 | where_field = email |
772 | where_field = email |
| 794 | hosts = unix:/var/run/mysqld/mysqld.sock |
773 | hosts = unix:/var/run/mysqld/mysqld.sock |
| 795 | </pre> |
774 | </pre> |
| 796 | |
775 | |
| 797 | <p> |
776 | <p> |
| 798 | Lastly, edit <path>/etc/postfix/main.cf</path> one more time. |
777 | Lastly, edit <path>/etc/postfix/main.cf</path> one more time. |
| 799 | </p> |
778 | </p> |
| 800 | |
779 | |
| 801 | <pre caption="/etc/postfix/main.cf"> |
780 | <pre caption="/etc/postfix/main.cf"> |
| 802 | # <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> |
| 803 | alias_maps = mysql:/etc/postfix/mysql-aliases.cf |
783 | alias_maps = mysql:/etc/postfix/mysql-aliases.cf |
| 804 | relocated_maps = mysql:/etc/postfix/mysql-relocated.cf |
784 | relocated_maps = mysql:/etc/postfix/mysql-relocated.cf |
| 805 | |
785 | |
| 806 | local_transport = local |
786 | local_transport = local |
| 807 | local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname |
787 | local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname |
| 808 | |
788 | |
| 809 | virtual_transport = virtual |
789 | virtual_transport = virtual |
| 810 | virtual_mailbox_domains = |
790 | <comment>(The domains listed by the mydestination should not be listed in |
| 811 | virt-bar.com, |
791 | the virtual_mailbox_domains parameter)</comment> |
| 812 | $other-virtual-domain.com |
792 | virtual_mailbox_domains = virt-domain.com, $other-virtual-domain.com |
| 813 | |
793 | |
| 814 | virtual_minimum_uid = 1000 |
794 | virtual_minimum_uid = 1000 |
|
|
795 | <comment>(Substitute $vmail-gid with the GID of the vmail group)</comment> |
| 815 | virtual_gid_maps = static:$vmail-gid |
796 | virtual_gid_maps = static:$vmail-gid |
| 816 | virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-maps.cf |
797 | virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-maps.cf |
| 817 | virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf |
798 | virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf |
|
|
799 | <comment>(Substitute $vmail-uid with the UID of the vmail user)</comment> |
| 818 | virtual_uid_maps = static:$vmail-uid |
800 | virtual_uid_maps = static:$vmail-uid |
| 819 | virtual_mailbox_base = / |
801 | virtual_mailbox_base = / |
| 820 | #virtual_mailbox_limit = |
802 | #virtual_mailbox_limit = |
| 821 | </pre> |
803 | </pre> |
| 822 | |
804 | |
| … | |
… | |
| 892 | to require a bit of hacking. I really recommend reading all of the mailman |
874 | to require a bit of hacking. I really recommend reading all of the mailman |
| 893 | documentation, including README.POSTFIX.gz, to understand what's being done |
875 | documentation, including README.POSTFIX.gz, to understand what's being done |
| 894 | here. |
876 | here. |
| 895 | </p> |
877 | </p> |
| 896 | |
878 | |
| 897 | <p> |
|
|
| 898 | One further note, current versions of mailman install to /usr/local/mailman. If |
|
|
| 899 | you're like me and wish to change the default install location, it can be |
|
|
| 900 | overridden in the ebuild filoe by changing the INSTALLDIR variable. |
|
|
| 901 | </p> |
|
|
| 902 | |
|
|
| 903 | <pre caption="/usr/portage/net-mail/mailman/mailman-$ver.ebuild"> |
|
|
| 904 | # <i>nano -w /usr/portage/net-mail/mailman/mailman-$ver.ebuild</i> |
|
|
| 905 | MAILGID="280" |
|
|
| 906 | <comment>(Set MAILGID to the mailman group instead of nobody |
|
|
| 907 | This is needed for postfix integration.)</comment> |
|
|
| 908 | </pre> |
|
|
| 909 | |
|
|
| 910 | <pre caption="Install mailman"> |
879 | <pre caption="Install mailman"> |
| 911 | # <i>emerge mailman</i> |
880 | # <i>emerge mailman</i> |
| 912 | <comment>(This package is currently masked as well, so you'll need to unmask it or give |
|
|
| 913 | emerge an explicit path to the ebuild. Once it's installed, follow the directions |
|
|
| 914 | in the README.gentoo.gz *except* do not add your aliases to /etc/mail/aliases. |
|
|
| 915 | We will instead be linking the entire alias db into postfix.)</comment> |
|
|
| 916 | |
|
|
| 917 | # <i>zless /usr/share/doc/mailman-$ver/README.gentoo.gz</i> |
|
|
| 918 | </pre> |
881 | </pre> |
| 919 | |
882 | |
| 920 | <pre caption="Setting defaults: Mailman/Defaults.py"> |
883 | <pre caption="Setting defaults: Mailman/Defaults.py"> |
| 921 | # <i> nano -w /var/mailman/Mailman/Defaults.py</i> |
884 | # <i> nano -w /usr/local/mailman/Mailman/Defaults.py</i> |
| 922 | <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> |
| 923 | DEFAULT_EMAIL_HOST = 'domain.com' |
886 | DEFAULT_EMAIL_HOST = 'domain.com' |
| 924 | DEFAULT_URL_HOST = 'www.domain.com' |
887 | DEFAULT_URL_HOST = 'www.domain.com' |
| 925 | </pre> |
888 | </pre> |
| 926 | |
889 | |
| 927 | <pre caption="mailman config: mm_cfg.py"> |
890 | <pre caption="mailman config: mm_cfg.py"> |
| 928 | # <i>nano -w /var/mailman/Mailman/mm_cfg.py</i> |
891 | # <i>nano -w /usr/local/mailman/Mailman/mm_cfg.py</i> |
| 929 | MTA = "Postfix" |
892 | MTA = "Postfix" |
| 930 | POSTFIX_STYLE_VIRTUAL_DOMAINS = ['virt-domain.com', 'virt.domain2.com'] |
893 | POSTFIX_STYLE_VIRTUAL_DOMAINS = ['virt-domain.com', 'virt.domain2.com'] |
| 931 | add_virtualhost('www.virt.domain.com', 'virt.domain.com') |
894 | add_virtualhost('www.virt.domain.com', 'virt.domain.com') |
| 932 | add_virtualhost('www.virt.domain2.com', 'virt.domain2.com') |
895 | add_virtualhost('www.virt.domain2.com', 'virt.domain2.com') |
| 933 | <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> |
| 934 | </pre> |
897 | </pre> |
| 935 | |
898 | |
| 936 | <pre caption="And last but not least"> |
899 | <pre caption="And last but not least"> |
| 937 | <comment>(Once that's finished, add your first list.)</comment> |
900 | <comment>(Once that's finished, add your first list.)</comment> |
| 938 | |
901 | |
| 939 | # <i>su mailman</i> |
902 | # <i>su mailman</i> |
| 940 | # <i>cd ~</i> |
903 | # <i>cd ~</i> |
| 941 | # <i>bin/newlist test</i> |
904 | # <i>./bin/newlist --urlhost='www.virt-domain.com' --emailhost='virt-domain.com' test</i> |
| 942 | Enter the email of the person running the list: <i>your@email.address</i> |
905 | Enter the email of the person running the list: <i>your@email.address</i> |
| 943 | Initial test password: |
906 | Initial test password: |
| 944 | Hit enter to continue with test owner notification... |
907 | Hit enter to continue with test owner notification... |
| 945 | <comment>(Virtual domain lists may be specified with |
908 | <comment>(Virtual domain lists may also be specified with |
| 946 | list@domain.com style list names.)</comment> |
909 | list@domain.com style list names.)</comment> |
| 947 | # <i>bin/genaliases</i> |
910 | # <i>./bin/genaliases</i> |
| 948 | <comment>(Now that your aliases have been generated, |
911 | <comment>(Now that your aliases have been generated, |
| 949 | verify that they were added successfully.)</comment> |
912 | verify that they were added successfully.)</comment> |
| 950 | |
913 | |
| 951 | # <i>nano -w data/aliases</i> |
914 | # <i>nano -w data/aliases</i> |
| 952 | # STANZA START: test |
915 | # STANZA START: test |
| 953 | # CREATED: |
916 | # CREATED: |
| 954 | test: "|/var/mailman/mail/mailman post test" |
917 | test: "|/usr/local/mailman/mail/mailman post test" |
| 955 | test-admin: "|/var/mailman/mail/mailman admin test" |
918 | test-admin: "|/usr/local/mailman/mail/mailman admin test" |
| 956 | test-bounces: "|/var/mailman/mail/mailman bounces test" |
919 | test-bounces: "|/usr/local/mailman/mail/mailman bounces test" |
| 957 | test-confirm: "|/var/mailman/mail/mailman confirm test" |
920 | test-confirm: "|/usr/local/mailman/mail/mailman confirm test" |
| 958 | test-join: "|/var/mailman/mail/mailman join test" |
921 | test-join: "|/usr/local/mailman/mail/mailman join test" |
| 959 | test-leave: "|/var/mailman/mail/mailman leave test" |
922 | test-leave: "|/usr/local/mailman/mail/mailman leave test" |
| 960 | test-owner: "|/var/mailman/mail/mailman owner test" |
923 | test-owner: "|/usr/local/mailman/mail/mailman owner test" |
| 961 | test-request: "|/var/mailman/mail/mailman request test" |
924 | test-request: "|/usr/local/mailman/mail/mailman request test" |
| 962 | test-subscribe: "|/var/mailman/mail/mailman subscribe test" |
925 | test-subscribe: "|/usr/local/mailman/mail/mailman subscribe test" |
| 963 | test-unsubscribe: "|/var/mailman/mail/mailman unsubscribe test" |
926 | test-unsubscribe: "|/usr/local/mailman/mail/mailman unsubscribe test" |
| 964 | # 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> |
| 965 | |
935 | |
| 966 | # <i>/etc/init.d/mailman start</i> |
936 | # <i>/etc/init.d/mailman start</i> |
| 967 | # <i>rc-update add mailman default</i> |
937 | # <i>rc-update add mailman default</i> |
| 968 | <comment>(To start mailman at once and on every reboot.)</comment> |
938 | <comment>(To start mailman at once and on every reboot.)</comment> |
| 969 | </pre> |
939 | </pre> |
| … | |
… | |
| 973 | owner_request_special = no |
943 | owner_request_special = no |
| 974 | recipient_delimiter = + |
944 | recipient_delimiter = + |
| 975 | <comment>(Read README.POSTFIX.gz for details on this.)</comment> |
945 | <comment>(Read README.POSTFIX.gz for details on this.)</comment> |
| 976 | |
946 | |
| 977 | alias_maps = |
947 | alias_maps = |
| 978 | hash:/var/mailman/data/aliases, |
948 | hash:/usr/local/mailman/data/aliases, |
| 979 | mysql:/etc/postfix/mysql-aliases.cf |
949 | mysql:/etc/postfix/mysql-aliases.cf |
| 980 | |
950 | |
| 981 | virtual_alias_maps = |
951 | virtual_alias_maps = |
| 982 | hash:/var/mailman/data/virtual-mailman, |
952 | hash:/usr/local/mailman/data/virtual-mailman, |
| 983 | mysql:/etc/postfix/mysql-virtual.cf |
953 | mysql:/etc/postfix/mysql-virtual.cf |
| 984 | <comment>(This adds mailman alias file support to postfix |
954 | <comment>(This adds mailman alias file support to postfix |
| 985 | You may of course use the mysql tables for this, |
955 | You may of course use the mysql tables for this, |
| 986 | but I hate doing that by hand. Also, if you are not |
956 | but I hate doing that by hand. Also, if you are not |
| 987 | using virtual domains, adding the virtual alias maps |
957 | using virtual domains, adding the virtual alias maps |
| 988 | to postfix may cause problems, be warned.)</comment> |
958 | to postfix may cause problems, be warned.)</comment> |
| … | |
… | |
| 1108 | sure it's using the current version. Some of the components will dump their |
1078 | sure it's using the current version. Some of the components will dump their |
| 1109 | current config's to you, like postfix. |
1079 | current config's to you, like postfix. |
| 1110 | </p> |
1080 | </p> |
| 1111 | |
1081 | |
| 1112 | <pre caption="Some services can dump their current config"> |
1082 | <pre caption="Some services can dump their current config"> |
| 1113 | # <i>apachectl fullstatus</i> (needs lynx installed) |
1083 | # <i>apache2ctl fullstatus</i> (needs lynx installed) |
| 1114 | # <i>apachectl configtest</i> (checks config sanity) |
1084 | # <i>apache2ctl configtest</i> (checks config sanity) |
| 1115 | # <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) |
| 1116 | # <i>/etc/init.d/$service restart</i> |
1086 | # <i>/etc/init.d/$service restart</i> |
| 1117 | </pre> |
1087 | </pre> |
| 1118 | |
1088 | |
| 1119 | </body> |
1089 | </body> |
| … | |
… | |
| 1133 | |
1103 | |
| 1134 | <pre caption="Checking the logs"> |
1104 | <pre caption="Checking the logs"> |
| 1135 | # <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) |
| 1136 | # <i>nano -w /var/log/mail/current</i> |
1106 | # <i>nano -w /var/log/mail/current</i> |
| 1137 | # <i>cat /var/log/mysql/mysql.log</i> |
1107 | # <i>cat /var/log/mysql/mysql.log</i> |
| 1138 | # <i>tail /var/log/apache/error_log</i> |
1108 | # <i>tail /var/log/apache2/error_log</i> |
| 1139 | </pre> |
1109 | </pre> |
| 1140 | |
1110 | |
| 1141 | <p> |
1111 | <p> |
| 1142 | You may also find the debug_peer parameters in main.cf helpful. Setting these |
1112 | You may also find the debug_peer parameters in main.cf helpful. Setting these |
| 1143 | will increase log output over just verbose mode. |
1113 | will increase log output over just verbose mode. |
| … | |
… | |
| 1226 | <li> |
1196 | <li> |
| 1227 | <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 |
| 1228 | google, which has never failed me |
1198 | google, which has never failed me |
| 1229 | </li> |
1199 | </li> |
| 1230 | <li> |
1200 | <li> |
| 1231 | 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 |
| 1232 | place to go for help. |
1202 | link="irc://irc.gentoo.org/gentoo">#gentoo</uri>. IRC is a great place to go |
|
|
1203 | for help. |
| 1233 | </li> |
1204 | </li> |
| 1234 | </ul> |
1205 | </ul> |
| 1235 | |
1206 | |
| 1236 | </body> |
1207 | </body> |
| 1237 | </section> |
1208 | </section> |