Make sure to turn on the following USE variables in <path>/etc/make.conf</path>

97

before compiling the packages: <c>USE="mysql imap libwww maildir

98

sasl ssl"</c>. Otherwise you will most likely have to recompile things to

99

get the support you need for all the protocols. Further, it's a good idea to

100

turn off any other mail and network variables, like ipv6.

101

</p>

102

103

<impo>

104

This howto was written for postfix-2.0.x. If you are using postfix &lt; 2 some

105

of the variables in this document will be different. It is recommended that you

106

upgrade. Some other packages included in this howto are version sensitive as

107

well. You are advised to read the documentation included with packages if you

108

run into issues with this.

109

</impo>

110

111

<impo>

112

This document uses apache-1.3.x. Apache-2 has been marked stable in portage.

113

However there are still a number of issues with php integration. Until php

114

support in apache-2.0.x is marked stable, this guide will continue to use the

115

1.3.x version.

116

</impo>

117

118

<impo>

119

You need a domain name to run a public mail server, or at least an MX record

120

for a domain. Ideally you would have control of at least two domains to take

121

advantage of your new virtual domain functionality.

122

</impo>

123

124

<impo>

125

Make sure <path>/etc/hostname</path> is set to the right hostname for your mail

126

server. Verify your hostname is set correctly with <c>hostname</c>. Also

127

verify that there are no conflicting entries in <path>/etc/hosts</path>.

128

</impo>

129

130

<note>

131

It is recommended that you read this entire document and familiarize yourself

132

with all the steps before attempting the install. If you run into problems with

133

any of the steps, check the troubleshooting guide at the end of this document.

134

Also, not all the referenced packages are necessary, this set up is very

135

flexible. For instance, if you do not desire a web interface, feel free to skip

136

the squirrelmail section.

137

</note>

138

36

<body>

139

</body>

37

<p>For most gentoo users, a simple mail client and fetchmail will do. However, if you're hosting a domain with your system, you'll need a full blown MTA (Mail Transfer Agent). And if you're hosting multiple domains, then you'll definitely need something more robust to handle all of the email for your users. This system was designed to be an elegant solution to that problem.</p>

140

</section>

38

<p>A virtual mail system needs to be able to handle email for numerous domains with multiple users over a variety of interfaces. This presents some issues that must be dealt with. For instance, what if you have two users on different domains that want the same user name? If you are providing imap access and smtp-auth, how do combine the various authentication daemons into a single system? How do you provide security for the numerous components that comprise the system? How do you manage it all?</p>

141

</chapter>

39

<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>

142

40

<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>

143

<chapter>

41

<p>The following packages are used in this setup:

144

<title>Postfix Basics</title>

145

<section>

146

<body>

147

148

<pre caption="Install postfix">

149

# <i>emerge postfix</i>

150

</pre>

151

152

<warn>

153

Verify that you have not installed any other MTA, such as ssmtp, exim, or

154

qmail, or you will surely have BIG problems.

155

</warn>

156

157

<p>

158

After postfix is installed, it's time to configure it. Change the following

159

options in <path>/etc/postfix/main.cf</path>:

160

</p>

161

162

<pre caption="/etc/postfix/main.cf">

163

myhostname = $host.domain.name

164

mydomain = $domain.name

165

inet_interfaces = all

166

mydestination = $myhostname, localhost.$mydomain $mydomain

167

mynetworks = my.ip.net.work/24, 127.0.0.0/8

168

home_mailbox = .maildir/

169

local_destination_concurrency_limit = 2

170

default_destination_concurrency_limit = 10

171

</pre>

172

173

<p>

174

Next change the following in <path>/etc/postfix/master.cf</path>. This will

<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>

198

</pre>

45

<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>

199

46

<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>

200

<p>

47

<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>

201

Now that postfix is running, fire up your favorite console mail client and send

48

<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>

202

yourself an email. I use <c>mutt</c> for all my console mail. Verify that

203

postfix is delivering mail to local users, once that's done, we're on to the

204

next step.

205

</p>

206

207

<note>

208

I strongly recommend that you verify this basic postfix setup is functioning

209

before you progress to the next step of the howto.

210

</note>

211

49

</body>

212

</body>

50

</chapter>

213

</section>

51

<chapter>

214

</chapter>

52

<title>Postfix Basics</title>

215

216

<chapter>

217

<title>Courier-imap</title>

218

<section>

219

<body>

220

221

<pre caption="Install courier-imap and courier-authlib">

222

# <i>emerge courier-imap courier-authlib</i>

223

</pre>

224

225

<pre caption="Courier-imap configuration">

226

# <i>cd /etc/courier-imap</i>

227

<comment>(If you want to use the ssl capabilities of courier-imap or pop3,

228

you'll need to create certs for this purpose.

229

This step is recommended. If you do not want to use ssl, skip this step.)</comment>

<codenote>Just add the <c>-v</c> after the smtpd in the above line</codenote>

76

</pre>

77

<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>

78

<pre caption="Starting postfix for the first time" >

79

# <i>/usr/bin/newaliases</i>

80

<codenote>This will install the new aliases. You only need to do this </codenote>

81

<codenote>when you update or install aliases.</codenote>

82

83

# <i>/etc/init.d/postfix start</i>

84

</pre>

85

<p>Now that postfix is running, fire up your favorite console mail client and send yourself an email. I use <c>mutt</c> for all my console mail. Verify that postfix is delivering mail to local users, once that's done, we're on to the next step.</p>

86

<note>I strongly recommend that you verify this basic postfix setup is functioning before you progress to the next step of the howto. </note>

87

</body>

88

</chapter>

89

<chapter>

90

<title>Courier-imap</title>

91

<body>

92

<pre caption="Install courier-imap" ># <i>emerge courier-imap</i>

93

</pre>

94

<pre caption="Courier-imap configuration" >

95

# <i>cd /etc/courier-imap</i>

96

<codenote>If you want to use the ssl capabilities of courier-imap or pop3, </codenote>

97

<codenote>you'll need to create certs for this purpose.</codenote>

98

<codenote>This step is recommended. If you do not want to use ssl, skip this step.</codenote>

<p>Start up your favorite mail client and verify that all connections you've started work for receiving and sending mail. Now that the basics work, we're going to do a whole bunch of stuff at once to get the rest of the system running. Again, please verify that what we've installed already works before progressing.</p>

114

</body>

115

</chapter>

116

<chapter>

117

<title>Cyrus-sasl</title>

118

<body>

119

<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>

120

<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>

121

<pre caption="Configuring and installing the cyrus-sasl ebuild" >

122

# <i>USE='-ldap -mysql' emerge cyrus-sasl</i>

123

<codenote>We don't have ldap and we're not using sasl's mysql capabilities </codenote>

124

<codenote>so we need to turn them off for this build.</codenote>

125

</pre>

126

<p>Next, edit <path>/var/lib/sasl2/smtp.conf</path>.</p>

127

<pre caption="Starting sasl" >

128

# <i>nano -w /var/lib/sasl2/smtp.conf</i>

129

pwcheck_method: saslauthd

130

mech_list: LOGIN PLAIN

131

<codenote>It's important to turn off auth mehtods we are not using.</codenote>

132

<codenote>They cause problems for some mail clients.</codenote>

133

# <i>/etc/init.d/saslauthd start</i>

134

</pre>

135

</body>

136

</chapter>

137

<chapter>

138

<title>SSL Certs for Postfix and Apache</title>

139

<body>

140

<p>Next we're going to make a set of ssl certificates for postfix and apache.</p>

141

<pre>

142

# <i>cd /etc/ssl/</i>

143

# <i>nano -w openssl.cnf</i>

144

<codenote>Change the following default values for your domain:</codenote>

145

146

countryName_default

147

stateOrProvinceName_default

148

localityName_default

149

0.organizationName_default

150

commonName_default

151

emailAddress_default.

152

153

<codenote>If the variables are not already present, just add them in a sensible place.</codenote>

154

155

156

# <i>cd misc</i>

157

# <i>nano -w CA.pl</i>

158

<codenote>We need to add -nodes to the # create a certificate and</codenote>

159

<codenote>#create a certificate request code in order to let our new ssl</codenote>

160

<codenote>certs be loaded without a password. Otherwise when you</codenote>

<codenote>smtpd_tls_auth_only is commented out to ease testing the system. </codenote>

392

<comment>(smtpd_tls_auth_only is commented out to ease testing the system.

223

<codenote>You can turn this on later if you desire.</codenote>

393

You can turn this on later if you desire.)</comment>

224

394

225

# <i>postfix reload</i>

395

# <i>postfix reload</i>

226

</pre>

396

</pre>

397

398

<p>

227

<p>Now we're going to verify that the config's we added were picked up by postfix.</p>

399

Now we're going to verify that the config's we added were picked up by postfix.

400

</p>

401

228

<pre caption="Verifying sasl and tls support">

402

<pre caption="Verifying sasl and tls support">

229

# <i>telnet localhost 25</i>

403

# <i>telnet localhost 25</i>

230

404

231

Trying 127.0.0.1...

405

Trying 127.0.0.1...

232

Connected to localhost.

406

Connected to localhost.

233

Escape character is '^]'.

407

Escape character is '^]'.

234

220 mail.domain.com ESMTP Postfix

408

220 mail.domain.com ESMTP Postfix

235

<i>EHLO domain.com</i>

409

<i>EHLO domain.com</i>

236

250-mail.domain.com

410

250-mail.domain.com

237

250-PIPELINING

411

250-PIPELINING

238

250-SIZE 10240000

412

250-SIZE 10240000

239

250-VRFY

413

250-VRFY

240

250-ETRN

414

250-ETRN

241

250-STARTTLS

415

250-STARTTLS

242

250-AUTH LOGIN PLAIN

416

250-AUTH LOGIN PLAIN

243

250-AUTH=LOGIN PLAIN

417

250-AUTH=LOGIN PLAIN

244

250-XVERP

418

250-XVERP

245

250 8BITMIME

419

250 8BITMIME

246

<i>^]</i>

420

<i>^]</i>

247

telnet> <i>quit</i>

421

telnet> <i>quit</i>

422

</pre>

423

424

<p>

425

Verify that the above AUTH and STARTTLS lines now appear in your postfix

426

install. As I said before, as it stands now AUTH will not work. that's because

427

sasl will try to auth against it's sasldb, instead of the shadow file for some

428

unknown reason, which we have not set up. So we're going to just plow through

429

and set up mysql to hold all of our auth and virtual domain information.

248

</pre>

430

</p>

249

<p>Verify that the above AUTH and STARTTLS lines now appear in your postfix install. As I said before, as it stands now AUTH will not work. that's because sasl will try to auth against it's sasldb, instead of the shadow file for some unknown reason, which we have not set up. So we're going to just plow through and set up mysql to hold all of our auth and virtual domain information.

<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://docs.csoft.net/micro/black-htaccess.html</uri>.</p>

554

318

<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:

555

<p>

556

Now we're going to install the Apache certificates we made previously. The

557

Apache-SSL directives that you need to use the resulting cert are:

558

</p>

559

319

<ul>

560

<ul>

320

<li>SSLCertificateFile /path/to/certs/new.cert.cert</li>

561

<li>SSLCertificateFile /path/to/certs/new.cert.cert</li>

321

<li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li>

562

<li>SSLCertificateKeyFile /path/to/certs/new.cert.key</li>

322

</ul>

563

</ul>

323

</p>

564

324

<pre caption="Install Apache SSL certificates">

565

<pre caption="Install Apache SSL certificates">

325

# <i>cp /usr/lib/ssl/misc/new.cert.cert /etc/apache/conf/ssl/</i>

566

# <i>cp /etc/ssl/misc/new.cert.cert /etc/apache/conf/ssl/</i>

326

# <i>cp /usr/lib/ssl/misc/new.cert.key /etc/apache/conf/ssl/</i>

567

# <i>cp /etc/ssl/misc/new.cert.key /etc/apache/conf/ssl/</i>

327

# <i>nano -w /etc/apache/conf/vhosts/ssl.default-vhost.conf</i>

568

# <i>nano -w /etc/apache/conf/vhosts/ssl.default-vhost.conf</i>

569

328

<codenote>Change the following parameters</codenote>

570

<comment>(Change the following parameters)</comment>

329

571

330

ServerName host.domain.name

572

ServerName host.domain.name

331

ServerAdmin your@email.address

573

ServerAdmin your@email.address

332

SSLCertificateFile /etc/apache/conf/ssl/new.cert.cert

574

SSLCertificateFile /etc/apache/conf/ssl/new.cert.cert

333

SSLCertificateKeyFile /etc/apache/conf/ssl/new.cert.key

575

SSLCertificateKeyFile /etc/apache/conf/ssl/new.cert.key

334

576

335

# <i>/etc/init.d/apache restart</i>

577

# <i>/etc/init.d/apache restart</i>

336

</pre>

578

</pre>

337

<note>If you have an existing apache install, you'll likely have to perform a full server reboot to install your new certificates. Check your logs to verify apache restarted successfully.</note>

579

580

<note>

581

If you have an existing apache install, you'll likely have to perform a full

<p>Now enter the phpmyadmin page and browse the tables. You'll want to add in your local aliases, edit your user table to add a test user, and change your transport table to add information about your domains. The default values supplied with the dumpfile should be a sufficient guide to what values need to go where. Make sure that if you put information in the database that it is accurate. For instance, make sure the local users home dir exists and that the correct uid/gid values are in place. The maildirs should be created automatically by postfix when the user receives their first email. So, in general, it's a good idea to send a &quot;Welcome&quot; mail to a new user after you setup their account to make sure the .maildir gets created. </p>

602

603

<p>

604

Now enter the phpmyadmin page and browse the tables. You'll want to add in your

supplied with the dumpfile should be a sufficient guide to what values need to

608

go where. Make sure that if you put information in the database that it is

609

accurate. For instance, make sure the local users home dir exists and that the

610

correct uid/gid values are in place. The maildirs should be created

611

automatically by postfix when the user receives their first email. So, in

612

general, it's a good idea to send a "Welcome" mail to a new user

613

after you setup their account to make sure the .maildir gets created.

614

</p>

615

352

</body>

616

</body>

617

</section>

353

</chapter>

618

</chapter>

619

354

<chapter>

620

<chapter>

355

<title>The vmail user</title>

621

<title>The vmail user</title>

622

<section>

356

<body>

623

<body>

357

<p>At this point you may be wondering what user and directory to use for virtual mail users, and rightly so. Let's set that up.</p>

624

625

<p>

626

At this point you may be wondering what user and directory to use for virtual

627

mail users, and rightly so. Let's set that up.

628

</p>

629

358

<pre caption="Adding the vmail user">

630

<pre caption="Adding the vmail user">

359

# <i>adduser -d /home/vmail -s /bin/false vmail</i>

631

# <i>adduser -d /home/vmail -s /bin/false vmail</i>

360

# <i>uid=`cat /etc/passwd | grep vmail | cut -f 3 -d :`</i>

632

# <i>uid=`cat /etc/passwd | grep vmail | cut -f 3 -d :`</i>

361

# <i>groupadd -g $uid vmail</i>

633

# <i>groupadd -g $uid vmail</i>

362

# <i>mkdir /home/vmail</i>

634

# <i>mkdir /home/vmail</i>

363

# <i>chown vmail. /home/vmail</i>

635

# <i>chown vmail: /home/vmail</i>

636

</pre>

637

638

<p>

639

So now when you're setting up vmail accounts, use the vmail uid, gid, and

640

homedir. When you're setting up local accounts, use that users uid, gid, and

641

homedir. We've been meaning to create a php admin page for this setup but

642

haven't gotten around to it yet, as phpmyadmin generally works fine for us.

364

</pre>

643

</p>

365

<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>

644

366

</body>

645

</body>

646

</section>

367

</chapter>

647

</chapter>

648

368

<chapter>

649

<chapter>

369

<title>Configuring MySQL Authentication and vhosts</title>

650

<title>Configuring MySQL Authentication and vhosts</title>

651

<section>

370

<body>

652

<body>

371

<p>Next we'll reconfigure our authentication to use the mailsql database in courier-imap and postfix. In all of the following examples, replace $password with the password you set for the mailsql mysql user.</p>

<p>As of Postfix 2.0.x, there were a number of significant changes over the 1.1.x release. Notably the transport, virtual-gid, and virtual-uid tables are no longer necessary. The tables are still included if you wish to use them.</p>

808

809

<p>

810

For security reasons you should change the permissions of the various

811

<path>/etc/mail/mysql-*.cf</path>:

812

</p>

813

814

<pre caption="Changing file permission">

815

# <i>chmod 640 /etc/postfix/mysql-*.cf</i>

816

# <i>chgrp postfix /etc/postfix/mysql-*.cf</i>

817

</pre>

818

819

<p>

820

As of Postfix 2.0.x, there were a number of significant changes over the 1.1.x

821

release. Notably the transport, virtual-gid, and virtual-uid tables are no

822

longer necessary. The tables are still included if you wish to use them.

823

</p>

824

825

<note>

532

<note>It is recommended tha you read VIRTUAL_README included with the postfix doc's for more information.</note>

826

It is recommended that you read VIRTUAL_README included with the postfix docs

827

for more information.

828

</note>

829

830

<pre caption="Make postfix reload its tables">

533

<pre># <i>postfix reload</i>

831

# <i>postfix reload</i>

832

</pre>

833

834

<p>

835

Now, if all went well, you should have a functioning mailhost. Users should be

836

able to authenticate against the sql database, using their full email address,

837

for pop3, imap, and smtp. I would highly suggest that you verify that

838

everything is working at this point. If you run into problems (with as many

839

things as this setup has going on, it's likely that you will) check the

840

troubleshooting section of this howto.

534

</pre>

841

</p>

535

<p>Now, if all went well, you should have a functioning mailhost. Users should be able to authenticate against the sql database, using their full email address, for pop3, imap, and smtp. I would highly suggest that you verify that everything is working at this point. If you run into problems (with as many things as this setup has going on, it's likely that you will) check the troubleshooting section of this howto.</p>

842

536

</body>

843

</body>

844

</section>

537

</chapter>

845

</chapter>

846

538

<chapter>

847

<chapter>

539

<title>Squirrelmail</title>

848

<title>Squirrelmail</title>

849

<section>

540

<body>

850

<body>

541

<pre>

851

852

<pre caption="Install squirrelmail">

542

# <i>emerge squirrelmail</i>

853

# <i>emerge squirrelmail</i>

543

<codenote>I like to add a link to the htdocs space for a shorter url.</codenote>

854

<comment>(Install squirrelmail to localhost so that it's accessed by http://localhost/mail)

<codenote>Now you should be able to login to squirrelmail, again - with your full email address,</codenote>

861

Now you should be able to login to squirrelmail, again - with your full email address,

550

<codenote>and use your new webmail setup.</codenote>

862

and use your new webmail setup.)</comment>

551

</pre>

863

</pre>

864

552

</body>

865

</body>

866

</section>

553

</chapter>

867

</chapter>

868

554

<chapter>

869

<chapter>

555

<title>Mailman</title>

870

<title>Mailman</title>

871

<section>

556

<body>

872

<body>

557

<p>Last step: mailman. The new version of mailman has very nice virtual domain support, which is why I use it, not to mention it's really a great package. To get this package installed and working correctly for virtual domains is going to require a bit of hacking. I really recommend reading all of the mailman documentation, including README.POSTFIX.gz, to understand what's being done here.</p>

873

558

<pre caption="/usr/portage/net-mail/mailman/mailman-$ver.ebuild">

874

<p>

559

# <i>nano -w /usr/portage/net-mail/mailman/mailman-$ver.ebuild</i>

875

Last step: mailman. The new version of mailman has very nice virtual domain

560

MAILGID="280"

876

support, which is why I use it, not to mention it's really a great package. To

561

<codenote>Set MAILGID to the mailman group instead of nobody</codenote>

877

get this package installed and working correctly for virtual domains is going

562

<codenote>This is needed for postfix integration</codenote>

878

to require a bit of hacking. I really recommend reading all of the mailman

879

documentation, including README.POSTFIX.gz, to understand what's being done

880

here.

563

</pre>

881

</p>

882

564

<pre>

883

<p>

884

One further note, current versions of mailman install to /usr/local/mailman. If

885

you're like me and wish to change the default install location, it can be

886

overridden in the ebuild filoe by changing the INSTALLDIR variable.

887

</p>

888

889

<pre caption="Install mailman">

565

# <i>emerge mailman</i>

890

# <i>emerge mailman</i>

566

<codenote>This package is currently masked as well, so you'll need to unmask it or give </codenote>

891

<comment>(This package is currently masked as well, so you'll need to unmask it or give

567

<codenote>emerge an explicit path to the ebuild. Once it's installed, follow the directions</codenote>

892

emerge an explicit path to the ebuild. Once it's installed, follow the directions

568

<codenote>in the README.gentoo.gz</codenote>

893

in the README.gentoo.gz *except* do not add your aliases to /etc/mail/aliases.

894

We will instead be linking the entire alias db into postfix.)</comment>

569

895

570

# <i>zless /usr/share/doc/mailman-$ver/README.gentoo.gz</i>

896

# <i>zless /usr/share/doc/mailman-$ver/README.gentoo.gz</i>

571

</pre>

897

</pre>

898

899

<pre caption="Setting defaults: Mailman/Defaults.py">

900

# <i> nano -w /var/mailman/Mailman/Defaults.py</i>

901

<comment>(Change the values below to reflect your primary domain, virtuals will be set next.)</comment>

<codenote>This is required for your virtual domains for mailman to function.</codenote>

912

<comment>(This is required for your virtual domains for mailman to function.)</comment>

579

</pre>

580

<pre>

913

</pre>

914

915

<pre caption="And last but not least">

581

<codenote>Once that's finished, add your first list.</codenote>

916

<comment>(Once that's finished, add your first list.)</comment>

582

917

583

# <i>su mailman</i>

918

# <i>su mailman</i>

584

# <i>cd ~</i>

919

# <i>cd ~</i>

585

# <i>bin/newlist test</i>

920

# <i>bin/newlist test</i>

586

Enter the email of the person running the list: your@email.address

921

Enter the email of the person running the list: <i>your@email.address</i>

587

Initial test password:

922

Initial test password:

588

Hit enter to continue with test owner notification...

923

Hit enter to continue with test owner notification...

589

<codenote>Virtual domain lists may be specified with</codenote>

924

<comment>(Virtual domain lists may be specified with

590

<codenote>list@domain.com style list names</codenote>

925

list@domain.com style list names.)</comment>

591

# <i>bin/genaliases</i>

926

# <i>bin/genaliases</i>

592

<codenote>Now that your aliases have been generated,</codenote>

927

<comment>(Now that your aliases have been generated,

593

<codenote>verify that they were added successfully.</codenote>

928

verify that they were added successfully.)</comment>

594

929

595

# <i>nano -w data/aliases</i>

930

# <i>nano -w data/aliases</i>

596

# STANZA START: test

931

# STANZA START: test

597

# CREATED:

932

# CREATED:

598

test: "|/var/mailman/mail/mailman post test"

933

test: "|/var/mailman/mail/mailman post test"

599

test-admin: "|/var/mailman/mail/mailman admin test"

934

test-admin: "|/var/mailman/mail/mailman admin test"

600

test-bounces: "|/var/mailman/mail/mailman bounces test"

935

test-bounces: "|/var/mailman/mail/mailman bounces test"

601

test-confirm: "|/var/mailman/mail/mailman confirm test"

936

test-confirm: "|/var/mailman/mail/mailman confirm test"

602

test-join: "|/var/mailman/mail/mailman join test"

937

test-join: "|/var/mailman/mail/mailman join test"

603

test-leave: "|/var/mailman/mail/mailman leave test"

938

test-leave: "|/var/mailman/mail/mailman leave test"

604

test-owner: "|/var/mailman/mail/mailman owner test"

939

test-owner: "|/var/mailman/mail/mailman owner test"

605

test-request: "|/var/mailman/mail/mailman request test"

940

test-request: "|/var/mailman/mail/mailman request test"

606

test-subscribe: "|/var/mailman/mail/mailman subscribe test"

941

test-subscribe: "|/var/mailman/mail/mailman subscribe test"

607

test-unsubscribe: "|/var/mailman/mail/mailman unsubscribe test"

942

test-unsubscribe: "|/var/mailman/mail/mailman unsubscribe test"

608

# STANZA END: test

943

# STANZA END: test

609

944

610

# <i>/etc/init.d/mailman start</i>

945

# <i>/etc/init.d/mailman start</i>

611

# <i>rc-update add mailman default</i>

946

# <i>rc-update add mailman default</i>

612

<codenote>To start mailman at once and on every reboot</codenote>

947

<comment>(To start mailman at once and on every reboot.)</comment>

613

</pre>

948

</pre>

614

949

615

<pre caption="Adding mailman alias support to postfix">

950

<pre caption="Adding mailman alias support to postfix">

616

# <i>nano -w /etc/postfix/main.cf</i>

951

# <i>nano -w /etc/postfix/main.cf</i>

617

owner_request_special = no

952

owner_request_special = no

618

recipient_delimiter = +

953

recipient_delimiter = +

619

<codenote>Read README.POSTFIX.gz for details on this</codenote>

954

<comment>(Read README.POSTFIX.gz for details on this.)</comment>

620

955

621

alias_maps =

956

alias_maps =

622

hash:/var/mailman/data/aliases,

957

hash:/var/mailman/data/aliases,

623

mysql:/etc/postfix/mysql-aliases.cf

958

mysql:/etc/postfix/mysql-aliases.cf

624

959

625

virtual_alias_maps =

960

virtual_alias_maps =

626

hash:/var/mailman/data/virtual-mailman,

961

hash:/var/mailman/data/virtual-mailman,

627

mysql:/etc/postfix/mysql-virtual.cf

962

mysql:/etc/postfix/mysql-virtual.cf

628

<codenote>This adds mailman alias file support to postfix</codenote>

963

<comment>(This adds mailman alias file support to postfix

629

<codenote>You may of course use the mysql tables for this,</codenote>

964

You may of course use the mysql tables for this,

630

<codenote>but I hate doing that by hand.</codenote>

965

but I hate doing that by hand. Also, if you are not

966

using virtual domains, adding the virtual alias maps

967

to postfix may cause problems, be warned.)</comment>

968

</pre>

969

970

<p>

971

You should now be able to setup mailing lists for any domain on your box. Last

972

note on this, make sure you run all mailman commands as the user mailman (<c>su

973

mailman</c>) or else the permissions will be wrong and you'll have to fix them.

974

Read the mailman doc's for more information on setting up and managing mailman

975

lists.

631

</pre>

976

</p>

632

<p> You should now be able to setup mailing lists for any domain on your box. Last note on this, make sure you run all mailman commands as the user mailman (<c>su mailman</c>) or else the permissions will be wrong and you'll have to fix them. Read the mailman doc's for more information on setting up and managing mailman lists.</p>

977

633

</body>

978

</body>

979

</section>

634

</chapter>

980

</chapter>

981

635

<chapter>

982

<chapter>

636

<title>Content Filtering and Anti-Virus</title>

983

<title>Content Filtering and Anti-Virus</title>

637

<body><p>Coming soon...it would be done already but I need some perl help and testing to make it so. If you'd like to volunteer for that, please email me.</p></body>

<p>Ok, you're all set, edit <path>/etc/postfix/master.cf</path> and turn off verbose mode for production use. You'll probably also want to add the services to your startup routine to make sure everything comes back up on a reboot. Make sure to add all the services you're using - apache, mysql, saslauthd, postfix, courier-imapd, courier-imapd-ssl, courier-pop3d, and courier-pop3d-ssl are all up to your decision on what access you want to provide. I generally have all the services enabled.</p>

1000

1001

<p>

1002

Ok, you're all set, edit <path>/etc/postfix/master.cf</path> and turn off

1003

verbose mode for production use. You'll probably also want to add the services

1004

to your startup routine to make sure everything comes back up on a reboot. Make

1005

sure to add all the services you're using - apache, mysql, saslauthd, postfix,

1006

courier-imapd, courier-imapd-ssl, courier-pop3d, and courier-pop3d-ssl are all

1007

up to your decision on what access you want to provide. I generally have all

1008

the services enabled.

1009

</p>

1010

643

<pre caption="Wrap up">

1011

<pre caption="Wrap up">

644

# <i>postfix reload</i>

1012

# <i>postfix reload</i>

645

# <i>rc-update add $service default</i>

1013

# <i>rc-update add $service default</i>

646

</pre>

1014

</pre>

1015

647

<p>

1016

<p>

648

<e>Have fun!</e>

1017

<e>Have fun!</e>

649

</p>

1018

</p>

1019

650

</body>

1020

</body>

1021

</section>

651

</chapter>

1022

</chapter>

1023

652

<chapter>

1024

<chapter>

653

<title>Troubleshooting</title>

1025

<title>Troubleshooting</title>

654

<section>

1026

<section>

655

<title>Introduction</title>

1027

<title>Introduction</title>

656

<body>

1028

<body>

657

<p>Troubleshooting: This is a short troubleshooting guide for the set up we've detailed how to install here. It is not exhaustive, but meant as a place to get you started in figuring out problems. With a complicated setup such as this, it's imperative that you narrow down the problem to the particular component that is malfunctioning. In general I do that by following a few steps. Start from the base of the system and work your way up, ruling out components that work along the way until you discover which component is having the problem.</p>

1029

1030

<p>

1031

Troubleshooting: This is a short troubleshooting guide for the set up we've

1032

detailed how to install here. It is not exhaustive, but meant as a place to get

1033

you started in figuring out problems. With a complicated setup such as this,

1034

it's imperative that you narrow down the problem to the particular component

1035

that is malfunctioning. In general I do that by following a few steps. Start

1036

from the base of the system and work your way up, ruling out components that

1037

work along the way until you discover which component is having the problem.

1038

</p>

1039

658

</body>

1040

</body>

659

</section>

660

<section>

1041

</section>

1042

<section>

661

<title>Step 1: Check your config files.</title>

1043

<title>Step 1: Check your config files</title>

662

<body>

1044

<body>

663

<p>Typos are killers, especially when dealing with authentication systems. Scan your config's and mailsql database for typo's. You can debug all you want, but if you're not passing the right information back and forth to your mail system, it's not going to work. If you make a change to a config file for a service, make sure you restart that service so that the config change gets picked up.</p>

1045

664

<pre>

1046

<p>

1047

Typos are killers, especially when dealing with authentication systems. Scan

1048

your config's and mailsql database for typo's. You can debug all you want, but

1049

if you're not passing the right information back and forth to your mail system,

1050

it's not going to work. If you make a change to a config file for a service,

1051

make sure you restart that service so that the config change gets picked up.

1052

</p>

1053

1054

<pre caption="How to restart a service">

665

# <i>/etc/init.d/service restart</i>

1055

# <i>/etc/init.d/service restart</i>

666

</pre>

1056

</pre>

1057

667

</body>

1058

</body>

668

</section>

1059

</section>

669

<section>

1060

<section>

670

<title>Step 2: Are all the necessary services actually running?</title>

1061

<title>Step 2: Are all the necessary services actually running?</title>

671

<body>

1062

<body>

672

<p>If it's not running, start it up. It's awful hard to debug a service that isn't running. Sometimes a service will act like it's started but still not function. Sometimes, when a bad config is used, or a bad transmission comes into a mail component, the service will hang and keep the port from being used by another process. Sometimes you can detect this with netstat. Or, if you've been at it awhile, just take a break and reboot your box in the meantime. That will clear out any hung services. Then you can come back fresh and try it again.</p>

1063

673

<pre>

1064

<p>

1065

If it's not running, start it up. It's awful hard to debug a service that isn't

1066

running. Sometimes a service will act like it's started but still not function.

1067

Sometimes, when a bad config is used, or a bad transmission comes into a mail

1068

component, the service will hang and keep the port from being used by another

1069

process. Sometimes you can detect this with netstat. Or, if you've been at it

1070

awhile, just take a break and reboot your box in the meantime. That will clear

1071

out any hung services. Then you can come back fresh and try it again.

1072

</p>

1073

1074

<pre caption="Checking the status of a service">

674

# <i>/etc/init.d/$service status</i>

1075

# <i>/etc/init.d/$service status</i>

675

# <i>netstat -a | grep $service (or $port)</i>

1076

# <i>netstat -a | grep $service (or $port)</i>

676

</pre>

1077

</pre>

1078

677

</body>

1079

</body>

678

</section>

1080

</section>

679

<section>

1081

<section>

680

<title>Step 3: Are all the service using the current config's?</title>

1082

<title>Step 3: Are all the service using the current config's?</title>

681

<body>

1083

<body>

682

<p>If you've recently made a change to a config file, restart that service to make sure it's using the current version. Some of the components will dump their current config's to you, like postfix.</p>

1084

683

<pre>

1085

<p>

1086

If you've recently made a change to a config file, restart that service to make

1087

sure it's using the current version. Some of the components will dump their

<p>Repeat after me, logs are my friend. My next troubleshooting stop is always the logs. Sometimes it's helpful to try a failed operation again then check the logs so that the error message is right at the bottom (or top depending on your logger) instead of buried in there somewhere. See if there is any information in your log that can help you diagnose the problem, or at the very least, figure out which component is having the problem.</p>

1103

695

<pre>

1104

<p>

1105

Repeat after me, logs are my friend. My next troubleshooting stop is always the

1106

logs. Sometimes it's helpful to try a failed operation again then check the

1107

logs so that the error message is right at the bottom (or top depending on your

1108

logger) instead of buried in there somewhere. See if there is any information

1109

in your log that can help you diagnose the problem, or at the very least,

You may also find the debug_peer parameters in main.cf helpful. Setting these

1122

will increase log output over just verbose mode.

700

</pre>

1123

</p>

701

<p>You may also find the debug_peer parameters in main.cf helpful. Setting these will increase log output over just verbose mode.</p>

1124

702

<pre caption="adding debug_peer support">

1125

<pre caption="adding debug_peer support">

703

# <i>nano -w /etc/postfix/main.cf</i>

1126

# <i>nano -w /etc/postfix/main.cf</i>

704

debug_peer_level = 5

1127

debug_peer_level = 5

705

debug_peer_list = $host.domain.name

1128

debug_peer_list = $host.domain.name

706

<codenote>Uncomment one of the suggested debugger</codenote>

1129

<comment>(Uncomment one of the suggested debugger

707

<codenote>commands as well.</codenote>

1130

commands as well.)</comment>

708

</pre>

1131

</pre>

1132

709

</body>

1133

</body>

710

</section>

711

<section>

1134

</section>

1135

<section>

712

<title>Step 5: Talk to the service itself.</title>

1136

<title>Step 5: Talk to the service itself</title>

713

<body>

1137

<body>

714

<p>SMTP, IMAP, and POP3 all respond to telnet sessions. As we've seen earlier when we verified postfix's config. Sometimes it's helpful to open a telnet session to the service itself and see what's happening.</p>

1138

715

<pre>

1139

<p>

1140

SMTP, IMAP, and POP3 all respond to telnet sessions. As we've seen earlier when

1141

we verified postfix's config. Sometimes it's helpful to open a telnet session

1142

to the service itself and see what's happening.

1143

</p>

1144

1145

<pre caption="Connect to a service with telnet">

716

# <i>telnet localhost $port</i>

1146

# <i>telnet localhost $port</i>

717

<codenote>SMTP is 25, IMAP is 143, POP3 is 110. You should receive at least an OK string,</codenote>

1147

<comment>(SMTP is 25, IMAP is 143, POP3 is 110. You should receive at least an OK string,

718

<codenote>letting you know that the service is running and ready to respond to requests.</codenote>

1148

letting you know that the service is running and ready to respond to requests.)</comment>

<title>Step 6: Sometimes only the big guns will give you the information you need: strace.</title>

1159

<title>Step 6: Sometimes only the big guns will give you the information you need: strace</title>

729

<body>

1160

<body>

730

<p>You should have this installed anyway. This is an invaluable tool for debugging software. You can start commands from the command line with strace and watch all the system calls as they happen. It often dumps a huge amount of information, so you'll either need to watch it realtime as you retry a failed transaction with the mail system, or dump the output to a file for review.</p>

1161

731

<pre>

1162

<p>

1163

You should have this installed anyway. This is an invaluable tool for debugging

1164

software. You can start commands from the command line with strace and watch

1165

all the system calls as they happen. It often dumps a huge amount of

1166

information, so you'll either need to watch it realtime as you retry a failed

1167

transaction with the mail system, or dump the output to a file for review.

1168

</p>

1169

1170

<pre caption="Using strace">

732

# <i>emerge strace</i>

1171

# <i>emerge strace</i>

733

# <i>strace $command</i>

1172

# <i>strace $command</i>

734

# <i>strace -p `ps -C $service -o pid=`</i>

1173

# <i>strace -p `ps -C $service -o pid=`</i>

735

</pre>

1174

</pre>

1175

736

</body>

1176

</body>

737

</section>

1177

</section>

738

<section>

1178

<section>

739

<title>Step 7: Research</title>

1179

<title>Step 7: Research</title>

740

<body>

1180

<body>

741

<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>

1181

1182

<p>

1183

Once you have the information, if you can diagnose and fix the problem, great!

1184

If not, you'll probably need to go digging on the net for information that will

1185

help you fix it. Here's a list of sites you can check to see if your error has

1186

already been resolved. There's also a really good howto on setting up smtp-auth