<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Jupiter's Weblog</title>
	<atom:link href="http://duynam.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://duynam.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Fri, 24 Aug 2007 06:16:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='duynam.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Jupiter's Weblog</title>
		<link>http://duynam.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://duynam.wordpress.com/osd.xml" title="Jupiter&#039;s Weblog" />
	<atom:link rel='hub' href='http://duynam.wordpress.com/?pushpress=hub'/>
		<item>
		<title></title>
		<link>http://duynam.wordpress.com/2007/08/24/10/</link>
		<comments>http://duynam.wordpress.com/2007/08/24/10/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 06:16:20 +0000</pubDate>
		<dc:creator>duynam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://duynam.wordpress.com/2007/08/24/10/</guid>
		<description><![CDATA[The Installation and Configuration of a Cisco PIX Firewall Xem file đính kèm. Một số nội dung cụ thể như sau: Mô hình: Internet &#124; External Router &#124;192.168.1.2 &#124; &#124;E0utside2 192.168.1.1 security0 &#8212;&#8212;- &#124; PIX &#124;&#8212;&#8211;E2MZ 172.17.1.1 security50 &#8212;&#8212;- &#124;E1:inside 172.16.0.1 security 100 &#124; &#124;172.16.0.2 Internal Router 172.16.0.0/24 network Cấu hình như sau: pixfirewall(config)# hostname [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=duynam.wordpress.com&amp;blog=1451871&amp;post=10&amp;subd=duynam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>The Installation and Configuration of a Cisco PIX Firewall</strong></p>
<p>Xem file đính kèm. Một số nội dung cụ thể như sau:</p>
<p><strong>Mô hình:</strong></p>
<p>Internet<br />
|<br />
External Router<br />
|192.168.1.2<br />
|<br />
|E0<img src="http://www.athena.com.vn/forum/images/smilies/redface.gif" class="inlineimg" border="0" />utside2 192.168.1.1 security0<br />
&#8212;&#8212;-<br />
| PIX |&#8212;&#8211;E2<img src="http://www.athena.com.vn/forum/images/smilies/biggrin.gif" class="inlineimg" border="0" />MZ 172.17.1.1 security50<br />
&#8212;&#8212;-<br />
|E1:inside 172.16.0.1 security 100<br />
|<br />
|172.16.0.2<br />
Internal Router<br />
172.16.0.0/24 network</p>
<p><strong>Cấu hình như sau:</strong><br />
pixfirewall(config)# hostname PIX1<br />
PIX1(config)#enable password cisco<br />
PIX1(config)#nameif ethernet2 DMZ sec50<br />
PIX1(config)#ip address dmz 172.17.1.1 255.255.255.0<br />
PIX1(config)#ip address inside 172.16.0.1 255.255.255.0<br />
PIX1(config)#ip address outside 192.168.1.1 255.255.255.0<br />
PIX1(config)#interface ethernet0 auto<br />
PIX1(config)#interface ethernet1 auto<br />
PIX1(config)#interface ethernet2 auto</p>
<p><strong>Có 4 kỹ thuật nat dùng trên PIX:</strong><br />
- Static nat: thực hiện map 1 ip &#8211; 1 registered ip<br />
- Dynamic nat: map 1 ip &#8211; 1 pool registered ip<br />
- Overloading: map multi-ip &#8211; 1 registered ip<br />
- Overlapping: is when IP addresses on your network are registered IP address and used by another network.</p>
<p>Nhưng thông thường sẽ cấu hình như sau:<br />
<strong>Dynamic nat:</strong><br />
PIX1(config)#global (outside) 1 192.168.1.254 netmask 255.255.255.0<br />
PIX1(config)#nat (inside) 1 172.16.0.0 255.255.255.0 0 0<br />
PIX1(config)#nat (dmz) 1 172.17.1.0 255.255.255.0 0 0<br />
Nghĩa là:<br />
1. Create a global address 192.168.1.254 with a tag ID of 1.<br />
2. Assign the network 172.16.0.0/24 behind the inside interface the NAT tag ID 1.<br />
3. Assign the network 172.17.1.0/24 behind the dmz interface the NAT tag ID 1.</p>
<p><strong>Static nat:</strong><br />
PIX1(config)#static (inside,dmz) 172.17.1.0 172.17.1.0 netmask 255.255.255.0 0 0<br />
PIX1(config)#static (dmz,outside) 192.168.1.10 172.17.1.10 netmask<br />
255.255.255.0 0 0<br />
PIX1(config)#static (dmz,outside) 192.168.1.20 172.17.1.20 netmask<br />
Nghĩa là<br />
1. Khi traffic đến từ inside network thì sẽ giữ nguyên ip<br />
2.Trafic từ outside khi đến IP 192.168.1.10 sẽ được gửi đến server có ip là 172.17.1.10<br />
3.Trafic từ outside khi đến IP 192.168.1.20 sẽ được gửi đến server có ip là 172.17.1.20</p>
<p><strong>- Để tăng cường security dùng ACL để cho phép 1 số traffic thông dụng:</strong><br />
PIX1(config)#access-list acl_inside permit tcp 172.16.0.0 255.255.255.0 any eq www<br />
PIX1(config)#access-list acl_inside permit tcp 172.16.0.0 255.255.255.0 any eq ftp<br />
PIX1(config)#access-list acl_inside permit tcp 172.16.0.0 255.255.255.0 any eq 443<br />
PIX1(config)# access-list acl_inside permit tcp 172.16.0.0 255.255.255.0 host<br />
172.17.1.20 eq smtp<br />
PIX1(config)#access-list acl_dmz permit tcp 172.17.1.0 255.255.255.0 any eq www<br />
PIX1(config)#access-list acl_dmz permit tcp host 172.17.1.20 any eq smtp<br />
PIX1(config)#access-list acl_outside permit tcp any host 192.168.1.20 eq smtp<br />
PIX1(config)#access-list acl_outside permit tcp any host 192.168.1.10 eq www<br />
PIX1(config)#access-list acl_outside permit tcp any host 192.168.1.10 eq 443<br />
PIX1(config)#access-group acl_inside in interface inside<br />
PIX1(config)#access-group acl_dmz in interface dmz<br />
PIX1(config)#access-group acl_outside in interface outside</p>
<p><strong>Cuối cùng cấu hình định tuyến:</strong><br />
PIX1(config)#route inside 172.16.0.0 255.255.255.0 172.16.0.2 1<br />
PIX1(config)#route outside 0 0 192.168.1.2 1<br />
PIX1(config)#wr mem</p>
<p><strong>Chú ý:</strong><br />
- Nhớ lưu lại cấu hình: PIX1(config)#wr mem<br />
- Xóa bảng translation: PIX1(config)#clear xlate<br />
- Cú pháp static (internal_if_name,external_if_name) global_ip local_ip netmask mask có cách dễ nhớ hơn là: static (high.low) low high<br />
- Các lệnh trong PIX là case-sensitive</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duynam.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duynam.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duynam.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duynam.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duynam.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duynam.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/duynam.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/duynam.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/duynam.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/duynam.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duynam.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duynam.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duynam.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duynam.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duynam.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duynam.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=duynam.wordpress.com&amp;blog=1451871&amp;post=10&amp;subd=duynam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://duynam.wordpress.com/2007/08/24/10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/30af098ae1325ecf0a6301bafc3a5f10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duynam</media:title>
		</media:content>

		<media:content url="http://www.athena.com.vn/forum/images/smilies/redface.gif" medium="image" />

		<media:content url="http://www.athena.com.vn/forum/images/smilies/biggrin.gif" medium="image" />
	</item>
		<item>
		<title>Postfix + MySQL</title>
		<link>http://duynam.wordpress.com/2007/08/13/postfix-mysql/</link>
		<comments>http://duynam.wordpress.com/2007/08/13/postfix-mysql/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 17:10:19 +0000</pubDate>
		<dc:creator>duynam</dc:creator>
				<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://duynam.wordpress.com/2007/08/13/postfix-mysql/</guid>
		<description><![CDATA[CentOS + Postfix + MySQL + TLS + SASL + Maildrop + SQLgrey + Amavisd + SpamAssassin + ClamAV + Courier-IMAP + Courier-POP3d + SqWebMail + Horde IMP Original of this document available at http://www.bowe.id.au/michael/isp/postfix-server.htm NAVIGATION LINKS MAIN CHAPTERS : INSTALL CENTOS TWEAK THE CENTOS INSTALL UPDATE ALL THE RPMS CREATE THE SSL CERTIFICATES MYSQL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=duynam.wordpress.com&amp;blog=1451871&amp;post=9&amp;subd=duynam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>CentOS + Postfix + MySQL + TLS + SASL +  Maildrop + SQLgrey + Amavisd + SpamAssassin +  ClamAV + Courier-IMAP + Courier-POP3d + SqWebMail + Horde IMP</h2>
<p>Original of this document available at <a href="http://www.bowe.id.au/michael/isp/postfix-server.htm"> http://www.bowe.id.au/michael/isp/postfix-server.htm</a></p>
<hr />
<table style="border-collapse:collapse;" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<h3>NAVIGATION LINKS</h3>
<p>MAIN CHAPTERS :</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#INSTALL_CENTOS">INSTALL CENTOS</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#TWEAK_THE_CENTOS_INSTALL">TWEAK THE CENTOS INSTALL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#UPDATE_ALL_THE_RPMS">UPDATE ALL THE RPMS</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#CREATE_THE_SSL_CERTIFICATES">CREATE THE SSL CERTIFICATES</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#MYSQL">MYSQL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#SASL">SASL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#POSTFIX">POSTFIX</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#INSTALL_A_2ND_ETHERNET_IP">INSTALL A 2ND ETHERNET IP</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#SQLGREY_GREYLISTING">SQLGREY GREYLISTING</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#COURIER-AUTHLIB">COURIER-AUTHLIB</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#MAILDROP">MAILDROP</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#COURIER-IMAP_/_COURIER-POP3D">COURIER-IMAP / COURIER-POP3D </a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#APACHE">APACHE</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#SQWEBMAIL">SQWEBMAIL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#CLAM_ANTIVIRUS">CLAM ANTIVIRUS</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#SPAMASSASSIN">SPAMASSASSIN</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#AMAVISD">AMAVISD</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#PUREFTPD">PUREFTPD</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#LAST_%20BITS_OF_CLEANUP">LAST BITS OF CLEANUP</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#SAMPLE_TEST_DATA">SAMPLE / TEST DATA</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#MRTG_/_SNMP">MRTG / SNMP</a></li>
</ul>
<p>OPTIONAL CHAPTERS ( FOR LARGER / MORE-COMPLEX  SERVERS )</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEDICATED_AMAVISD_SERVER">DEDICATED AMAVISD SERVER</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#HORDE_SUITE">HORDE SUITE</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEFAULT_IMAP_POP3_DOMAIN_PER_HOSTNAME">SETTING A DEFAULT IMAP/POP3 DOMAIN PER HOSTNAME</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEFAULT_SQWEBMAIL_DOMAIN_PER_HOSTNAME">SETTING A DEFAULT SQWEBMAIL DOMAIN PER HOSTNAME</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEFAULT_SMTP-AUTH_DOMAIN_PER_HOSTNAME">SETTING A DEFAULT SMTP-AUTH DOMAIN PER HOSTNAME</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEFAULT_PURE-FTPD_DOMAIN_PER_HOSTNAME">SETTING A DEFAULT PURE-FTPD DOMAIN PER HOSTNAME</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#HOSTING_MULTIPLE_SSL_DOMAINS">HOSTING MULTIPLE SSL DOMAINS FOR COURIER-IMAP/POP3D</a></li>
<li><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" /><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#NO_CLEAR_PASSWORDS">WHAT TO DO IF YOU DONT HAVE CLEAR PASSWORDS AVAILABLE</a></li>
<li><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" /><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#HELO_FILTERING_FOR_POSTFIX">HELO  	FILTERING FOR POSTFIX</a></li>
</ul>
<p>&#8220;UNDER CONSTRUCTION&#8221; CHAPTERS</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#HOSTING_MULTIPLE_SSL_DOMAINS_FOR_APACHE_/_SQWEBMAIL">HOSTING MULTIPLE SSL DOMAINS FOR APACHE / SQWEBMAIL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#HOSTING_MULTIPLE_SSL_DOMAINS_FOR_POSTFIX">HOSTING MULTIPLE SSL DOMAINS FOR POSTFIX</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#WHAT_TO_DO_IF_YOU_DONT_WANT_TO_USE_SSL">WHAT TO DO IF YOU DONT WANT TO USE SSL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#FUZZYOCR">FUZZYOCR</a></li>
</ul>
<p>OTHER</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#MISC_NOTES">MISC NOTES</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#TODO">TODO</a></li>
</ul>
</td>
<td valign="top"><!-- google_ad_client = "pub-4778638820405329"; google_ad_width = 160; google_ad_height = 600; google_ad_format = "160x600_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "336699"; google_color_bg = "FFFFFF"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "008000"; //-->      </td>
</tr>
</table>
<hr />CentOS is an Enterprise-class Linux Distribution derived from Redhat  Enterprise Linux &#8211; pretty much the only difference is the Redhat branding has  been removed. As such CentOS is a great choice of O/S because you can be assured  it will be stable and well supported for drivers.</p>
<p>Fedora is another O/S that is very similar to CentOS. This guide will work  fine on Fedora as well, with no changes required to the installation steps. If  you are going to use Fedora there are a few things you need to be aware of :</p>
<ul>
<li>Use at least Fedora Core 4, as this gives you MySQL v4. FC3 and earlier    has MySQL v3. You want at least MySQL v4 as so you have access to some important performance improvements    such as query caching.</li>
<li>Each Fedora Core release only includes a very short period of update    maintenance. Typically updates are only available for the previous-to-current    version of Fedora. So for example if the current version is FC5, you will soon    not be able to get any more mainstream RPM updates for FC3. This is a large    contrast to CentOS which is based on RHEL where you have updates available for    years. Availability of updates is a very important security consideration.</li>
</ul>
<p>If you are going to host more than few hundred mailboxes, I would suggest you  have at least 2 disk drives in the server. IDE drives are OK, but SCSI (  possibly running in RAID configuration) will give better results when there are  high disk loads</p>
<p>It is possible to build large servers using this design. Examples built  include :</p>
<ul>
<li>60K mailboxes, Dual Xeon 2.8Ghz, 2Gb RAM, 2 x SCSI disk RAID1 for O/S, 4  	x SCSI disk RAID5 for mailboxes, 2 x P4 Amavisd offload machines</li>
<li>45K mailboxes, Dual Opteron 248, 2Gb RAM, 2 x Raptor SATA RAID1 for O/S,  	6 x Raptor RAID5 for mailboxes, 2 x P4 Amavisd offload machines</li>
<li>45K mailboxes, Dual Xeon 2.8Ghz, 1.5Gb RAM, 2 x SCSI disk RAID1 for O/S,  	4 x SCSI disk RAID5 for mailboxes, 2 x P4 Amavisd offload machines</li>
</ul>
<blockquote><p>With these servers, the system load values on the mailserver are  	typically around 5 peaking at about 10. The Amavis boxes have similar  	readings. POP3 and SqWebMail used mainly, with a little bit of IMAP and IMP.  	Common to see around 100 POP3 sessions active. SMTP-MX concurrency set  	around 100, Maildrop concurrency set around 20.</p></blockquote>
<hr />
<h3><a name="INSTALL_CENTOS"></a>INSTALL CENTOS</h3>
<p><a href="http://www.centos.org/">http://www.centos.org</a></p>
<p>Boot the CentOS 4.4 disk</p>
<p>Language selection :English (English)</p>
<p>Keyboard Configuration : US English</p>
<p>Upgrade Examine : Install CentOS</p>
<p>Installation Type : Server</p>
<p>Disk Partition Setup : Manually partition with Disk Druid</p>
<blockquote><p>Your 1st disk doesn&#8217;t need to be very large.</p>
<ul>
<li>/boot : ext3, 256Mb, force to be primary partition</li>
<li>/tmp : ext3 &#8211; 2000Mb, force to be primary partition</li>
<li>swap : 2000Mb, force to be primary partition</li>
<li>/  : ext3 &#8211; Fill to max available size, force to be primary partition</li>
</ul>
<p>Your 2nd disk should be large. If its an IDE drive, you should put it on a    separate controller to the 1st disk:</p>
<ul>
<li>/var/vmail : ext3, Fill to max available size, force to be primary    partition. (This is where all our mailboxes and user websites are going to    live)</li>
</ul>
<p>If your server is going to be busy, and you have a 3rd disk you can make    further enhancements. The disk doesn&#8217;t need to be very large. Note, that if    you have IDE drives, then this 3rd drive wont really help much unless you have    a 3rd IDE controller available</p>
<ul>
<li>/var/spool/postfix : ext3. (Postfix uses this location for storing      queued mail.)</li>
</ul>
</blockquote>
<p>Boot Loader Configuration : press next</p>
<p>Network Configuration :</p>
<ul>
<li>Choose eth0, edit
<ul>
<li>Configure using DHCP : unticked</li>
<li>Activate on boot : ticked</li>
<li>IP address : eg 192.168.1.10</li>
<li>Netmask : eg 255.255.255.0</li>
</ul>
</li>
<li>Set hostname manually : ticked</li>
<li>Gateway : eg 192.168.1.1</li>
<li>Primary DNS : eg 192.168.1.2</li>
<li>Secondary DNS : eg 192.168.1.3</li>
</ul>
<p>Firewall Configuration :</p>
<ul>
<li>Enable Firewall</li>
<li>Tick : SSH, HTTP, FTP, SMTP</li>
<li>Enable Selinux : Disabled</li>
</ul>
<p>Additional Language Support :</p>
<ul>
<li>Tick : English ( Australia )</li>
<li>Choose English (Australia) from the dropdown box at the top</li>
</ul>
<p>Timezone Selection :</p>
<ul>
<li>Choose your city on the map</li>
<li>System clock uses UTC : Unticked</li>
</ul>
<p>Set root Password : ChooseSomethingGood!</p>
<p>Package Group Selection :</p>
<ul>
<li>Leave default selections as-is, except for :</li>
<li>Editors : tick</li>
<li>Windows file server : untick</li>
<li>MySQL database : tick, Click on details, mysql-server : tick</li>
<li>Development tools : tick</li>
<li>Printing support : untick</li>
</ul>
<hr />
<h3><a name="TWEAK_THE_CENTOS_INSTALL"></a>TWEAK THE CENTOS INSTALL</h3>
<p>Configure the internationalisation settings. By default CentOS will set UTF8  ( Unicode ) character encoding schemes. but I find this causes problems with the  console display in my SSH client. Also some perl programs are known to have  problems with the UTF8</p>
<blockquote>
<pre>cp /etc/sysconfig/i18n /etc/sysconfig/i18n.original
vi /etc/sysconfig/i18n</pre>
<blockquote>
<pre># Remove any UTF-8 entries from the LANG line
# ie change it from LANG="en_US.UTF-8" to LANG="en_US"</pre>
<pre>LANG="en_US"</pre>
</blockquote>
</blockquote>
<p>Import the GPG keys for software packages</p>
<blockquote><p><font face="Courier New, Courier, mono" size="2">rpm &#8211;import /usr/share/rhn/RPM-GPG-KEY*</font></p></blockquote>
<p>Configure the log rotation scheme, to rotate daily, for 30 days, compressing  the old logs</p>
<blockquote>
<pre> vi /etc/logrotate.conf</pre>
<blockquote>
<pre>#weekly
daily</pre>
<pre>#rotate 4
rotate 30</pre>
<pre>#compress
compress</pre>
</blockquote>
</blockquote>
<p>Configure the NTP clock sync ( very important that mail servers have correct  clock! )</p>
<blockquote>
<pre>vi /etc/ntp.conf</pre>
<blockquote>
<pre>#server 0.pool.ntp.org
#server 1.pool.ntp.org
#server 2.pool.ntp.org
server ntp.<font color="#ff0000">yourdomain.com</font></pre>
</blockquote>
</blockquote>
<p>Tweak the firewall rules. Need to add some extra ports</p>
<blockquote>
<pre>TCP 20  : ftp-data
TCP 21  : ftp
TCP 110 : pop3
TCP 143 : imap
TCP 443 : https
TCP 465 : smtps
TCP 993 : imaps
TCP 995 : pop3s
UDP 161 : snmp</pre>
<pre>vi /etc/sysconfig/iptables</pre>
<blockquote>
<pre>-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 465 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 993 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 161 -j ACCEPT</pre>
</blockquote>
</blockquote>
<p>Configure which services are starting at boot time. The aim is to disable any  unneeded services.</p>
<blockquote>
<pre>chkconfig apmd off
chkconfig bluetooth off
chkconfig cpuspeed off
chkconfig cups off
chkconfig httpd on
chkconfig isdn off
chkconfig mysqld on
chkconfig netfs off
chkconfig nfslock off
chkconfig ntpd on
chkconfig pcmcia off
chkconfig portmap off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig saslauthd off
chkconfig sendmail off</pre>
<pre># these two are in Fedora, but not CentOS
chkconfig mDNSResponder off
chkconfig nifd off</pre>
</blockquote>
<p>For your spool and mailbox partitions, set the noatime flag. This is an important performance tweak which works by preventing the need for writing any updates to the disk when processes are reading files ( eg when Postfix&#8217;s qmgr process scans mail in the queue ). I had a busy server where loads dropped from a steady 20 to sub 10&#8242;s by making this simple change! Also, as a security precaution, tweak the fstab, to disable /tmp from permitting SUID or exec functionality.</p>
<blockquote>
<pre>vi /etc/fstab</pre>
<blockquote>
<pre>LABEL=/tmp /tmp ext3 defaults<strong>,nosuid,noexec</strong> 1 2</pre>
<pre>LABEL=/var/vmail /var/vmail ext3 defaults<strong>,noatime</strong> 1 2</pre>
<pre># and if you made a dedicated partition for the postfix mail queue...
LABEL=/var/spool/postf /var/spool/postfix ext3 defaults<strong>,noatime</strong> 1 2</pre>
</blockquote>
</blockquote>
<p>That noexec fstab tweak has an unfortunate side-effect of causing the &#8220;logrotate&#8221;  script to break. A workaround for this is :</p>
<blockquote>
<pre>mkdir /var/logrotate.tmp</pre>
<pre>vi /etc/cron.daily/logrotate</pre>
<blockquote>
<pre>#!/bin/sh
<strong>export TMPDIR=/var/logrotate.tmp
</strong>/usr/sbin/logrotate /etc/logrotate.conf</pre>
</blockquote>
</blockquote>
<p>Take advantage of the colors and other advanced features of the vim editor, compared with basic vi editor</p>
<blockquote>
<pre># only required on Fedora, a CentOS install appears to already default to vim
echo "alias vi='vim'" &gt;&gt; /root/.bashrc</pre>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />If you are using CentOS, you can  grab the &#8220;fastestmirror plugin&#8221; for yum, as this should allow your rpm downloads  to run quicker</p>
<blockquote>
<pre>yum install centos-yum yum-plugin-fastestmirror</pre>
<pre>vi /etc/yum.conf</pre>
<blockquote>
<pre>plugins=1</pre>
</blockquote>
</blockquote>
<p>Then give the server a reboot</p>
<blockquote>
<pre>shutdown -r now</pre>
</blockquote>
<hr />
<h3><a name="UPDATE_ALL_THE_RPMS"></a>UPDATE ALL THE RPMS</h3>
<p>Run the update manager. It will go and look for updated RPMs, then will  download and install them.</p>
<table style="border-collapse:collapse;" border="1" cellpadding="3" cellspacing="3">
<tr>
<td>TIP : If you are running a 64 bit platform eg Opteron, add this line to      the /etc/yum.conf to prevent conflicts between the 64bit and non-64bit      libraries</p>
<blockquote>
<pre>vi /etc/yum.conf</pre>
<blockquote>
<pre># add this line if you are running 64bit
exclude=*.i386 *.i586 *.i686</pre>
</blockquote>
</blockquote>
</td>
</tr>
</table>
<p>Be warned that the first update pass on Fedora can be pretty large. Its not  uncommon to see 250M+ of updates to be downloaded. CentOS isnt so &#8220;bleeding  edge&#8221; so for that platform there are usually a lot less updates to download.</p>
<blockquote>
<pre>yum update</pre>
</blockquote>
<p>Enable ongoing auto-updating</p>
<blockquote>
<pre>crontab -e</pre>
<blockquote>
<pre># Keep up to date. Lets only do it during business hours, just to be safe <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
#
# Dont download kernel updates, or our /boot will overflow eventually.
# Dont download mysql updates, as I have seen mysql shutdown and not automatically come back up.
#
# If we want to update kernel or mysql, we can run these manually via a "yum update".
50 10 * * 1-5 /usr/bin/yum --exclude=kernel* --exclude=hal --exclude=mysql*  -y update</pre>
</blockquote>
</blockquote>
<p>Give the server are reboot, so the new kernel that yum downloaded can take  effect</p>
<blockquote>
<pre>shutdown -r now</pre>
</blockquote>
<hr />
<h3><a name="CREATE_THE_SSL_CERTIFICATES"></a>CREATE THE SSL CERTIFICATES</h3>
<p>SSL certificates will be used by Postfix (for SMTPS and TLS), Courier (for    IMAPS and POP3S) and Apache (for HTTPS)</p>
<blockquote>
<pre>mkdir /usr/local/ssl
cd /usr/local/ssl</pre>
<pre># Generate the RSA private-key for the server.
# We don't want a pass phrase on this key, otherwise it will need to be entered
# every time courier/apache/postfix starts.
openssl genrsa -out mail.<font color="#ff0000">yourdomain.com</font>.key 1024</pre>
<blockquote>
<pre><span style="background-color:#c0c0c0;">Generating RSA private key, 1024 bit long modulus
...................++++++
........................++++++
e is 65537 (0x10001)</span></pre>
</blockquote>
<pre># Tighten the permissions on this key file
chmod 600 mail.<font color="#ff0000">yourdomain.com</font>.key</pre>
<pre># Generate a certificate request
openssl req -new -key mail.<font color="#ff0000">yourdomain.com</font>.key -out mail.<font color="#ff0000">yourdomain.com</font>.csr</pre>
<blockquote>
<pre><span style="background-color:#c0c0c0;">You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:AU
State or Province Name (full name) [Berkshire]:South Australia
Locality Name (eg, city) [Newbury]:Adelaide
Organization Name (eg, company) [My Company Ltd]:Yourcompany Limited
Organizational Unit Name (eg, section) []:Hosting Services
Common Name (eg, your name or your server's hostname) []:mail.<font color="#ff0000">yourdomain.com</font>
Email Address []:postmaster@</span><font color="#ff0000"><span style="background-color:#c0c0c0;">yourdomain.com</span></font><span style="background-color:#c0c0c0;">

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:password
An optional company name []:</span></pre>
</blockquote>
</blockquote>
<p>At this point you would send your CSR off to a Certificate Authority for      signing (such as Verisign or Thawte) . However if you wanted to do some      in-house testing, we can set ourselves up as a CA, and then sign the CSR      ourselves :</p>
<blockquote>
<pre># generate RSA private-key for the CA
openssl genrsa -des3 -out ca.key 1024</pre>
<blockquote>
<pre><span style="background-color:#c0c0c0;">Generating RSA private key, 1024 bit long modulus
.....................++++++
...............++++++
e is 65537 (0x10001)
Enter pass phrase for ca.key:capass
Verifying - Enter pass phrase for ca.key:capass</span></pre>
</blockquote>
<pre># tighten permissions on this private key
chmod 600 ca.key</pre>
<pre># create a self signed CA certificate
openssl req -new -x509 -days 365 -key ca.key -out ca.crt</pre>
<blockquote>
<pre><span style="background-color:#c0c0c0;">Enter pass phrase for ca.key:capass
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:AU
State or Province Name (full name) [Berkshire]:SomeState
Locality Name (eg, city) [Newbury]:SomePlace
Organization Name (eg, company) [My Company Ltd]:Test CA Company
Organizational Unit Name (eg, section) []:SomeGroup
Common Name (eg, your name or your server's hostname) []:CA Signing Biz
Email Address []:postmaster@nowhere</span></pre>
</blockquote>
<pre># Use this test CA to sign our server cert
openssl x509 -req -days 365 -CA ca.crt -CAkey ca.key -set_serial 01 -in mail.<font color="#ff0000">yourdomain.com</font>.csr -out mail.<font color="#ff0000">yourdomain.com</font>.crt</pre>
<blockquote>
<pre><span style="background-color:#c0c0c0;">Signature ok
subject=/C=AU/ST=SomeState/L=SomePlace/O=Test CA Company/OU=SomeGroup/CN=CA Signing Biz/emailAddress=postmaster@nowhere
Getting CA Private Key
Enter pass phrase for ca.key:capass</span></pre>
</blockquote>
</blockquote>
<p>Combine the server key and certificate into a single file. Postfix and      Apache can deal with two separate files, but Courier needs them both in one.      To try and keep things consistent we will use a single file with all 3 apps</p>
<blockquote>
<pre># create the PEM file in the format that courier wants (both the key and the cert in one file)
cat mail.<font color="#ff0000">yourdomain.com</font>.key mail.<font color="#ff0000">yourdomain.com</font>.crt &gt; mail.<font color="#ff0000">yourdomain.com</font>.pem
chmod 600 mail.<font color="#ff0000">yourdomain.com</font>.pem</pre>
</blockquote>
<p>OK so you should now have something like this :</p>
<blockquote>
<pre>ls -al</pre>
<pre>total 36
drwxr-xr-x   2 root root 4096 Nov 28 22:02 .
drwxr-xr-x  14 root root 4096 Nov 20 21:50 ..
-rw-r--r--   1 root root 1371 Nov 28 21:50 ca.crt
-rw-------   1 root root  963 Nov 28 21:47 ca.key
-rw-r--r--   1 root root 1001 Nov 28 21:51 mail.<font color="#ff0000">yourdomain.com</font>.crt
-rw-r--r--   1 root root  773 Nov 28 21:45 mail.<font color="#ff0000">yourdomain.com</font>.csr
-rw-------   1 root root  887 Nov 28 21:45 mail.<font color="#ff0000">yourdomain.com</font>.key
-rw-------   1 root root 1888 Nov 28 22:02 mail.<font color="#ff0000">yourdomain.com</font>.pem</pre>
</blockquote>
<hr />
<h3><a name="MYSQL"></a>MYSQL</h3>
<p><a href="http://www.mysql.com/">http://www.mysql.com</a></p>
<p>MySQL has been installed as part of the CentOS installation. Databases will be stored in /var/lib/mysql</p>
<p>Tune, based on how busy the MySQL is going to be. There are a few sample cnf  files supplied so choose the one that best matches your needs. (IMPORTANT NOTE : MySQL  query caching isn&#8217;t enabled in any of the sample files except for my-large and  my-huge. If you decide to use one of the smaller config files, it will be  worth you while to copy the <font face="Courier New" size="2">query_cache_size</font> setting across  from the large/huge files)</p>
<blockquote>
<pre>mv /etc/my.cnf /etc/my.cnf.original
cp /usr/share/doc/mysql-server-4.1.20/my-medium.cnf /etc/my.cnf</pre>
</blockquote>
<p>. Edit the config file and make the following tweaks <strong>in the [mysqld]  	section</strong></p>
<blockquote>
<pre>vi /etc/my.cnf</pre>
<blockquote>
<pre># put this one in if its not there already
query_cache_size= 64M</pre>
<pre># Our databases will only be accessed by programs running locally, so disable TCP connections and replication functions
skip-networking
#log-bin</pre>
<pre>#Add an entry to tweak the max number of allowed connections
#The default is 100. On a busy server you will probably need to increase this
max_connections = 400</pre>
<pre># Record of any queries that run slowly
log-slow-queries</pre>
</blockquote>
</blockquote>
<p>Create the MySQL tables for Postfix to use.</p>
<blockquote>
<pre>mysql</pre>
<blockquote>
<pre>GRANT SELECT ON postfix.* TO postfixuser@localhost IDENTIFIED BY 'postfixpass';</pre>
<pre>CREATE DATABASE postfix;
USE postfix;</pre>
<pre>CREATE TABLE mailbox_domains (</pre>
<blockquote>
<pre>domain varchar(255) NOT NULL default '',
description varchar(255) NOT NULL default 'Postfix virtual mailbox domain',
maxaliases int(10) NOT NULL default '-1',
maxmailboxes int(10) NOT NULL default '-1',
maxquota int(10) NOT NULL default '-1',
server varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
modified_by varchar(255) NOT NULL default '',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (domain)</pre>
</blockquote>
<pre>) TYPE=MyISAM COMMENT='Postfix Virtual Mailbox Domains';</pre>
<pre>CREATE TABLE mailbox (</pre>
<blockquote>
<pre>email varchar(255) NOT NULL default '',
password varchar(255) NOT NULL default '',
clear_password varchar(255) NOT NULL default '',
name varchar(255) NOT NULL default '',
maildir varchar(255) NOT NULL default '',
mailquota int(10) NOT NULL default '20',
ftpquota int(10) NOT NULL default '20',
disableftp tinyint(1) NOT NULL default '0',
<span style="background-color:#ccffff;">disableimap tinyint(1) NOT NULL default '0',
disablepop3 tinyint(1) NOT NULL default '0',
</span><span style="background-color:#ccffff;">disablewebmail tinyint(1) NOT NULL default '0',
</span>disablesmtpauth tinyint(1) NOT NULL default '0',
<span style="background-color:#ccffcc;">virus_lover tinyint(1) default NULL,
</span><span style="background-color:#ccffcc;">spam_lover tinyint(1) default NULL,
</span><span style="background-color:#ccffcc;">banned_files_lover tinyint(1) default NULL,
</span><span style="background-color:#ccffcc;">bad_header_lover tinyint(1) default NULL,
</span><span style="background-color:#ccffcc;">bypass_virus_checks tinyint(1) default NULL,
</span><span style="background-color:#ccffcc;">bypass_spam_checks tinyint(1) default NULL,
</span><span style="background-color:#ccffcc;">bypass_banned_checks tinyint(1) default NULL,
</span><span style="background-color:#ccffcc;">bypass_header_checks tinyint(1) default NULL,
spam_tag2_level float default NULL,
</span><span style="background-color:#ccffcc;">spam_kill_level float default NULL,</span>
server varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
modified_by varchar(255) NOT NULL default '',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (email)</pre>
</blockquote>
<pre>) TYPE=MyISAM COMMENT='Postfix - Virtual Mailbox Maps';</pre>
<pre>CREATE TABLE alias_domains (</pre>
<blockquote>
<pre>domain varchar(255) NOT NULL default '',
description varchar(255) NOT NULL default 'Postfix virtual alias domain',
maxaliases int(10) NOT NULL default '-1',
server varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
modified_by varchar(255) NOT NULL default '',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (domain)</pre>
</blockquote>
<pre>) TYPE=MyISAM COMMENT='Postfix Virtual Alias Domains';</pre>
<pre>CREATE TABLE alias (</pre>
<p align="left">
<blockquote>
<pre>address varchar(255) NOT NULL default '',
goto text NOT NULL,
server varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
modified_by varchar(255) NOT NULL default '',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (address)</pre>
</blockquote>
<pre>) TYPE=MyISAM COMMENT='Postfix - Virtual Alias Maps';</pre>
<pre>CREATE TABLE client_access (</pre>
<blockquote>
<pre>client varchar(255) NOT NULL default '',
response varchar(255) NOT NULL default '',
note varchar(255) NOT NULL default '',
server varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
modified_by varchar(255) NOT NULL default '',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (client)</pre>
</blockquote>
<pre>) TYPE=MyISAM COMMENT='Postfix - Client Access';</pre>
<pre>CREATE TABLE sender_access (</pre>
<blockquote>
<pre>sender varchar(255) NOT NULL default '',
response varchar(255) NOT NULL default '',
note varchar(255) NOT NULL default '',
server varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
modified_by varchar(255) NOT NULL default '',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (sender)</pre>
</blockquote>
<pre>) TYPE=MyISAM COMMENT='Postfix - Sender Access';</pre>
<pre>CREATE TABLE recipient_access (</pre>
<blockquote>
<pre>recipient varchar(255) NOT NULL default '',
response varchar(255) NOT NULL default '',
note varchar(255) NOT NULL default '',
server varchar(255) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
modified_by varchar(255) NOT NULL default '',
active tinyint(1) NOT NULL default '1',
PRIMARY KEY (recipient)</pre>
</blockquote>
<pre>) TYPE=MyISAM COMMENT='Postfix - Recipient Access';</pre>
<pre>quit</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="SASL"></a>SASL ( FOR SMTP-AUTH )</h3>
<p><a href="http://asg.web.cmu.edu/cyrus/download/sasl/"> http://asg.web.cmu.edu/cyrus/download/sasl/</a></p>
<p>Grab the SQL modules for SASL</p>
<blockquote>
<pre>yum install cyrus-sasl-sql cyrus-sasl-devel</pre>
</blockquote>
<p>Create a config file so that Postfix will be able to use the SASL libraries to do SMTP  authentications via MySQL</p>
<blockquote>
<pre>vi /usr/lib/sasl2/postfix.conf</pre>
<blockquote>
<pre>pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: CRAM-MD5 DIGEST-MD5 PLAIN LOGIN
sql_engine: mysql
sql_hostnames: localhost
sql_user: postfixuser
sql_passwd: postfixpass
sql_database: postfix
sql_verbose: yes
sql_select: SELECT clear_password FROM mailbox WHERE email='%u@%r' AND disablesmtpauth=0</pre>
</blockquote>
<table style="border-collapse:collapse;" border="1" cellpadding="3" cellspacing="3">
<tr>
<td>TIP : If you are using x86_64 platform ( eg Opteron ), you will need        to put this file in a different place:</p>
<pre>/usr/lib<strong>64</strong>/sasl2/postfix.conf</pre>
</td>
</tr>
</table>
</blockquote>
<hr />
<h3><a name="POSTFIX"></a>POSTFIX</h3>
<p><a href="http://www.postfix.org/">http://www.postfix.org/</a></p>
<p>Remove sendmail ( which is installed by default on CentOS )</p>
<blockquote>
<pre>yum remove sendmail</pre>
</blockquote>
<p>Install the prerequisites</p>
<blockquote>
<pre>yum install pcre-devel</pre>
</blockquote>
<p>Add the required user accounts to run the Postfix MTA</p>
<blockquote>
<pre>groupadd -r postfix
useradd -r -g postfix -d /no/where -s /no/shell postfix</pre>
<pre>groupadd -r postdrop</pre>
</blockquote>
<p>Before we forget, tighten up the permissions on the SASL conf file, as it    contains the database username/password</p>
<blockquote>
<pre>chown root.postfix /usr/lib/sasl2/postfix.conf
chmod 640 /usr/lib/sasl2/postfix.conf</pre>
</blockquote>
<p>Add the account that will own all the virtual mail</p>
<blockquote>
<pre>groupadd -g 1001 vmail
useradd -u 1001 -s /sbin/nologin -g vmail vmail</pre>
</blockquote>
<p>Download and extract the Postfix sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="ftp://ftp.planetmirror.com/pub/postfix/official/postfix-2.4.1.tar.gz">ftp://ftp.planetmirror.com/pub/postfix/official/postfix-2.4.1.tar.gz</a></pre>
<pre>tar xzf postfix-2.4.1.tar.gz
chown -R root.root postfix-2.4.1
cd postfix-2.4.1</pre>
</blockquote>
<p>Compile, enabling the optional support for MySQL, SASL (SMTP-AUTH), SSL (SMTPS and TLS)</p>
<blockquote>
<pre>make -f Makefile.init makefiles \
  'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS -I/usr/include/openssl' \
  'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -lsasl2 -lssl -lcrypto'</pre>
<pre>make</pre>
<pre>make install
# (press enter to all the "make install" questions)</pre>
</blockquote>
<table style="border-collapse:collapse;" border="1" cellpadding="3" cellspacing="3">
<tr>
<td>TIP : If you are using x86_64 platform ( eg Opteron ), you will need to      use a slightly modified make :</p>
<pre>make -f Makefile.init makefiles \
  'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS -I/usr/include/openssl' \
  'AUXLIBS=-L/usr/lib<strong>64</strong>/mysql -lmysqlclient -lz -lm -lsasl2 -lssl -lcrypto'</pre>
</td>
</tr>
</table>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Some  applications expect the sendmail binary to be available at /usr/lib/sendmail,  but Postfix doesn&#8217;t put it there, so lets make a symlink</p>
<blockquote>
<pre>ln -s /usr/sbin/sendmail /usr/lib/sendmail</pre>
</blockquote>
<pre>vi /etc/postfix/master.cf</pre>
<blockquote>
<pre># Now enabled SMTP over SSL (smtps : port 465)
#
# To do this, we need to edit the maser.cf file.
# The two line are already there, but are commented out.
# To enable the service, we simply need to remove the comment markers ("#").
#
# Note, there needs to be whitespace (either a space or tab) at the start of the 2nd line (in front of the -o)</pre>
<pre>smtps inet n - n - - smtpd
 -o smtpd_tls_wrappermode=yes
 -o smtpd_sasl_auth_enable=yes</pre>
</blockquote>
<pre>vi /etc/postfix/main.cf</pre>
<blockquote>
<pre># make the following changes :</pre>
<p align="left">
<pre>myhostname	= mail.<font color="#ff0000">yourdomain.com</font>
mydomain	= <font color="#ff0000">yourdomain.com</font></pre>
<p align="left">
<pre>mydestination	= $myhostname, localhost.$mydomain, localhost
local_recipient_maps = unix:passwd.byname $alias_maps</pre>
<p align="left">
<pre>mynetworks	= $config_directory/mynetworks
relayhost	= [smarthost.<font color="#ff0000">yourdomain.com</font>]  #&lt;-- if you have a smarthost server</pre>
<p align="left">
<pre>alias_maps	= hash:/etc/aliases</pre>
<p align="left">
<pre>home_mailbox	= Maildir/</pre>
<p align="left">
<pre># Next, add all these to the bottom of the file :</pre>
<p align="left">
<pre>disable_vrfy_command	= yes
smtpd_recipient_limit	= 250
biff			= no
# (note this setting below only affects LOCAL mail delivery agent, not virtual mailboxes)
mailbox_size_limit	= 20480000
maximal_queue_lifetime	= 5d
message_size_limit	= 18000000
delay_warning_time	= 4h
default_process_limit	= 50
append_dot_mydomain	= no
parent_domain_matches_subdomains =</pre>
<p align="left">
<pre>###################################################################################
### ENABLE SASL SUPPORT ( SMTP-AUTH )
# smtpd_sasl_auth_enable	= yes
#   Enable SASL support in postfix
# smtpd_sasl_security_options	= noanonymous
#   Anonymous logins will not be permitted
# broken_sasl_auth_clients	= yes
#   Allow RFC-broken mail clients like Outlook Express4 to use SMTP AUTH
<tt># smtpd_sasl_path		= postfix
#   Tells SASL to get the config from /usr/lib/sasl2/<strong>postfix</strong>.conf</tt>
# smtpd_sasl_local_domain	=
#   If the user fails to nominate a domain, don't auto append one
# smtpd_sasl_authenticated_header = yes
#   Include the authenticated username in the message headers.
#   Having this on will make it easier if a spammer cracks one of your user's weak passwords,
#   and starts using SMTP-AUTH to relay spam through your server</pre>
<p align="left">
<pre>smtpd_sasl_auth_enable		= yes
smtpd_sasl_security_options	= noanonymous
broken_sasl_auth_clients	= yes
<tt>smtpd_sasl_path			= <strong>postfix</strong></tt>
smtpd_sasl_local_domain		=
smtpd_sasl_authenticated_header = yes</pre>
<p align="left">
<pre>###################################################################################
<font face="Courier New, Courier, mono" size="2">### ENABLE TLS SUPPORT ( "STARTTLS" ... enables SSL to be negotiated during a SMTP connection )
# smtp_use_tls = no
#   dont enable TLS for outbound SMTP connections
</font># smtpd_use_tls = yes
#   announce TLS availability for incoming SMTP connections
# smtpd_tls_auth_only = no :
<font face="Courier New, Courier, mono" size="2">#   TLS is optional, not enforced</font>
<font face="Courier New, Courier, mono" size="2"># smtpd_tls_key_file :
#   specify the private key ( must not be encrypted - ie no password)
# smtpd_tls_cert_file :
#   specify the certificate
# smtpd_tls_session_cache_database :
#   nominate a server-side TLS session cache. Improves performance.
# smtpd_tls_loglevel = 1 :
#   log basic TLS handshake and cert info
# smtpd_tls_received_header = yes
#   record some protocol/cipher etc info in the Received header smtp_use_tls = no</font></pre>
<p align="left">
<pre><font face="Courier New, Courier, mono" size="2">smtp_use_tls                     = no
smtpd_use_tls                    = yes
smtpd_tls_auth_only              = no
smtpd_tls_key_file               = /usr/local/ssl/mail.<font color="#ff0000">yourdomain.com</font>.key
smtpd_tls_cert_file              = /usr/local/ssl/mail.<font color="#ff0000">yourdomain.com</font>.crt
smtpd_tls_session_cache_database = btree:/etc/postfix/tls_smtpd_scache
smtpd_tls_loglevel               = 1
smtpd_tls_received_header        = yes</font></pre>
<p align="left">
<pre>###################################################################################
### add $smtpd_recipient_restrictions to the standard list
### so that we can "proxy:" the check_client|sender|recipient_access entries
proxy_read_maps =
  $local_recipient_maps,
  $mydestination,
  $virtual_alias_maps,
  $virtual_alias_domains,
  $virtual_mailbox_maps,
  $virtual_mailbox_domains,
  $relay_recipient_maps,
  $relay_domains,
  $canonical_maps,
  $sender_canonical_maps,
  $recipient_canonical_maps,
  $relocated_maps,
  $transport_maps,
  $mynetworks,
  $smtpd_recipient_restrictions</pre>
<p align="left">
<pre>###################################################################################
### DEFINE OUR SMTPD RESTRICTIONS, RELAY CONTROL, RBL BLOCKING ETC
smtpd_helo_restrictions	=
smtpd_client_restrictions =
smtpd_sender_restrictions =</pre>
<p align="left">
<pre>smtpd_recipient_restrictions =
	check_client_access	proxy:mysql:/etc/postfix/mysql-client-access.cf,
	check_sender_access	proxy:mysql:/etc/postfix/mysql-sender-access.cf,
	check_recipient_access	proxy:mysql:/etc/postfix/mysql-recipient-access.cf,
	permit_sasl_authenticated,<span style="background-color:#00ffff;">
</span>	permit_mynetworks,
	reject_unauth_destination,
	reject_invalid_helo_hostname,
	reject_non_fqdn_sender,
	reject_non_fqdn_recipient,
	reject_unknown_sender_domain,
	reject_unknown_recipient_domain,
	reject_rbl_client list.dsbl.org,
	reject_rbl_client cbl.abuseat.org,
	reject_rbl_client dnsbl.njabl.org,
	permit</pre>
<p align="left">
<pre>smtpd_data_restrictions =
	reject_unauth_pipelining,
	permit</pre>
<p align="left">
<pre>###################################################################################
### Virtual alias config
virtual_alias_domains 	= proxy:mysql:/etc/postfix/mysql-virtual-alias-domains.cf
virtual_alias_maps 	= proxy:mysql:/etc/postfix/mysql-virtual-alias-maps.cf,
                          proxy:mysql:/etc/postfix/mysql-virtual-mailbox-to-alias-maps.cf</pre>
<p align="left">
<pre>###################################################################################
### Virtual mailbox config
# virtual_mailbox_domains : A list of all the virtual mailbox domains
# virtual_mailbox_base	: This value will be prepended to all the virtual_mailbox_maps
# virtual_mailbox_maps	: Virtual email addr to disk location mappings
# virtual_mailbox_limit	: Maximal size of an individual mailbox/Maildir file</pre>
<p align="left">
<pre>virtual_mailbox_domains	= proxy:mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_base	= /var/vmail
virtual_mailbox_maps	= proxy:mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_mailbox_limit	= 20480000</pre>
<p align="left">
<pre>virtual_transport       = maildrop
maildrop_destination_recipient_limit = 1</pre>
</blockquote>
<p>Create the config files that tell Postfix how to access the various MySQL tables.</p>
<p>Note &#8220;hosts = localhost&#8221; means Postfix will use sockets, &#8220;hosts = 127.0.0.1&#8243; means    Postfix will use    TCP.    We have disabled TCP access in MySQL (with the &#8220;skip-networking&#8221;    config option), so make sure you stick with    using the word localhost  in these files. Also, sockets are  faster than TCP.</p>
<blockquote>
<pre>echo "user = postfixuser" &gt; /etc/postfix/mysql-virtual-mailbox-domains.cf
echo "password = postfixpass" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-domains.cf
echo "hosts = localhost" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-domains.cf
echo "dbname = postfix" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-domains.cf
echo "query = SELECT 'ignored by postfix' FROM mailbox_domains WHERE domain='%s' AND active=1"  &gt;&gt; /etc/postfix/mysql-virtual-mailbox-domains.cf</pre>
<pre>echo "user = postfixuser" &gt; /etc/postfix/mysql-virtual-mailbox-maps.cf
echo "password = postfixpass" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-maps.cf
echo "hosts = localhost" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-maps.cf
echo "dbname = postfix" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-maps.cf
echo "query = SELECT 'ignored by postfix' FROM mailbox WHERE email='%s' AND active=1" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-maps.cf</pre>
<pre>echo "user = postfixuser" &gt; /etc/postfix/mysql-virtual-alias-domains.cf
echo "password = postfixpass" &gt;&gt; /etc/postfix/mysql-virtual-alias-domains.cf
echo "hosts = localhost" &gt;&gt; /etc/postfix/mysql-virtual-alias-domains.cf
echo "dbname = postfix" &gt;&gt; /etc/postfix/mysql-virtual-alias-domains.cf
echo "query = SELECT 'ignored by postfix' FROM alias_domains WHERE domain='%s' AND active=1" &gt;&gt; /etc/postfix/mysql-virtual-alias-domains.cf</pre>
<pre>echo "user = postfixuser" &gt; /etc/postfix/mysql-virtual-alias-maps.cf
echo "password = postfixpass" &gt;&gt; /etc/postfix/mysql-virtual-alias-maps.cf
echo "hosts = localhost" &gt;&gt; /etc/postfix/mysql-virtual-alias-maps.cf
echo "dbname = postfix" &gt;&gt; /etc/postfix/mysql-virtual-alias-maps.cf
echo "query = SELECT goto FROM alias WHERE address='%s' AND active=1" &gt;&gt; /etc/postfix/mysql-virtual-alias-maps.cf</pre>
<pre>echo "user = postfixuser" &gt; /etc/postfix/mysql-client-access.cf
echo "password = postfixpass" &gt;&gt; /etc/postfix/mysql-client-access.cf
echo "hosts = localhost" &gt;&gt; /etc/postfix/mysql-client-access.cf
echo "dbname = postfix" &gt;&gt; /etc/postfix/mysql-client-access.cf
echo "query = SELECT response FROM client_access WHERE client = '%s' AND active=1" &gt;&gt; /etc/postfix/mysql-client-access.cf</pre>
<pre>echo "user = postfixuser" &gt; /etc/postfix/mysql-sender-access.cf
echo "password = postfixpass" &gt;&gt; /etc/postfix/mysql-sender-access.cf
echo "hosts = localhost" &gt;&gt; /etc/postfix/mysql-sender-access.cf
echo "dbname = postfix" &gt;&gt; /etc/postfix/mysql-sender-access.cf
echo "query = SELECT response FROM sender_access WHERE sender = '%s' AND active=1" &gt;&gt; /etc/postfix/mysql-sender-access.cf</pre>
<pre>echo "user = postfixuser" &gt; /etc/postfix/mysql-recipient-access.cf
echo "password = postfixpass" &gt;&gt; /etc/postfix/mysql-recipient-access.cf
echo "hosts = localhost" &gt;&gt; /etc/postfix/mysql-recipient-access.cf
echo "dbname = postfix" &gt;&gt; /etc/postfix/mysql-recipient-access.cf
echo "query = SELECT response FROM recipient_access WHERE recipient = '%s' AND active=1" &gt;&gt; /etc/postfix/mysql-recipient-access.cf</pre>
<pre>#THIS IS A WORKAROUND TO ALLOW US TO USE CATCHALL ENTRIES IN THE VIRTUAL ALIAS MAPS.
#
# This issue is that Postfix will process all the alias entries before looking at the
# virtual mailbox maps. Thus if you add a catchall entry for a virtual mailbox domain,
# the catchall will grab all mail, and no mail will go to the virtual mailboxes.
#
# The only solution for virtual mailbox domains that have a catchall, is to populate
# all the mailbox addresses into the alias table as well. The mailbox entries need to
# be pointed back to themselves eg
#
# ADDRESS GOTO
# user1@domain -&gt; user1@domain
# user2@domain -&gt; user2@domain
# @domain -&gt; somewhere
#
# However we don't want to pollute our alias table with all these workaround records,
# so we will define a lookup now that lets Postfix do the work for us. Then we modify
# main.cf so that virtual_alias_maps changes from this :
#
# virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual-alias-maps.cf
#
# to this :
#
# virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual-alias-maps.cf,
# proxy:mysql:/etc/postfix/mysql-virtual-mailbox-to-alias-maps.cf
#
# NOTE: I "stole" this workaround from
# <a href="http://workaround.org/articles/ispmail-sarge/#mysql-virtual_email2email.cf">http://workaround.org/articles/ispmail-sarge/#mysql-virtual_email2email.cf</a>
#
echo "user = postfixuser" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-to-alias-maps.cf
echo "password = postfixpass" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-to-alias-maps.cf
echo "hosts = localhost" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-to-alias-maps.cf
echo "dbname = postfix" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-to-alias-maps.cf
echo "query = SELECT email FROM mailbox WHERE email='%s' AND active=1" &gt;&gt; /etc/postfix/mysql-virtual-mailbox-to-alias-maps.cf</pre>
<pre># these files contain our database username/password, so tighten the security a bit
chown root.postfix /etc/postfix/mysql-*.cf
chmod 640 /etc/postfix/mysql-*.cf</pre>
</blockquote>
<p>Now we need to populate the mynetworks file. This file lists the IPs that are able  to &#8220;relay&#8221; mail through your server. We put localhost into this file, so that  scripts running on this server can relay mail to the internet. If you have  workstations on a LAN, or other users on the internet with fixed-ip addresses,  you can add them here as well, and these users will then be permitted to relay  mail. For all other users who have mailboxes on your server, when sending mail  they can either use SMTP-AUTH, or alternatively they could set their email  client&#8217;s SMTP server settings to point to their ISP&#8217;s mail server.</p>
<blockquote>
<pre>echo '# Localhost' &gt; /etc/postfix/mynetworks
echo '127.0.0.0/8' &gt;&gt;/etc/postfix/mynetworks
echo '' &gt;&gt;/etc/postfix/mynetworks
echo '# MyCompany blocks' &gt;&gt;/etc/postfix/mynetworks
echo 'xxx.xxx.xxx.xxx/24' &gt;&gt;/etc/postfix/mynetworks
echo 'yyy.yyy.yyy.yyy/24' &gt;&gt;/etc/postfix/mynetworks</pre>
</blockquote>
<p>Double check that syslog is configured not to fsync after every output to  maillog ( <a href="http://www.postfix.org/LINUX_README.html">as this would bog server down badly</a> )</p>
<blockquote>
<pre>vi /etc/syslog.conf</pre>
<blockquote>
<pre>-/var/log/maillog</pre>
</blockquote>
</blockquote>
<p>Create a init script for postfix</p>
<blockquote>
<pre>echo '#!/bin/bash' &gt; /etc/rc.d/init.d/postfix
echo '#' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# postfix      Postfix Mail Transfer Agent' &gt;&gt; /etc/rc.d/init.d/postfix
echo '#' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# chkconfig: 2345 80 30' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# description: Postfix is a Mail Transport Agent, which is the program \' &gt;&gt; /etc/rc.d/init.d/postfix
echo '#              that moves mail from one machine to another.' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# processname: master' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# pidfile: /var/spool/postfix/pid/master.pid' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# config: /etc/postfix/main.cf' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# config: /etc/postfix/master.cf' &gt;&gt; /etc/rc.d/init.d/postfix
echo '#' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# Source function library.' &gt;&gt; /etc/rc.d/init.d/postfix
echo '. /etc/rc.d/init.d/functions' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# Source networking configuration.' &gt;&gt; /etc/rc.d/init.d/postfix
echo '. /etc/sysconfig/network' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# Check that networking is up.' &gt;&gt; /etc/rc.d/init.d/postfix
echo '[ ${NETWORKING} = "no" ] &amp;&amp; exit 0' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo '[ -x /usr/sbin/postfix ] || exit 0' &gt;&gt; /etc/rc.d/init.d/postfix
echo '[ -d /etc/postfix ] || exit 0' &gt;&gt; /etc/rc.d/init.d/postfix
echo '[ -d /var/spool/postfix ] || exit 0' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'RETVAL=0' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'start() {' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        # Start daemons.' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        echo -n $"Starting postfix: "' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        alias_database=$(postconf -h alias_database 2&gt;/dev/null)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        RETVAL=$?' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        if [ $RETVAL -ne 0 ]; then' &gt;&gt; /etc/rc.d/init.d/postfix
echo '            failure $"determination of alias_database"' &gt;&gt; /etc/rc.d/init.d/postfix
echo '            echo' &gt;&gt; /etc/rc.d/init.d/postfix
echo '            return 0' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        fi' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        if [ -n "$alias_database" ]; then' &gt;&gt; /etc/rc.d/init.d/postfix
echo '            /usr/sbin/postalias ${alias_database//,} 2&gt;/dev/null' &gt;&gt; /etc/rc.d/init.d/postfix
echo '            RETVAL=$?' &gt;&gt; /etc/rc.d/init.d/postfix
echo '            if [ $RETVAL -ne 0 ]; then' &gt;&gt; /etc/rc.d/init.d/postfix
echo '                failure $"postalias $alias_database"' &gt;&gt; /etc/rc.d/init.d/postfix
echo '                echo' &gt;&gt; /etc/rc.d/init.d/postfix
echo '                return 0' &gt;&gt; /etc/rc.d/init.d/postfix
echo '            fi' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        fi' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        /usr/sbin/postfix start 2&gt;/dev/null 1&gt;&amp;2 &amp;&amp; success || failure $"postfix start"'	&gt;&gt; /etc/rc.d/init.d/postfix
echo '        RETVAL=$?' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        [ $RETVAL -eq 0 ] &amp;&amp; touch /var/lock/subsys/postfix' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        echo' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        return $RETVAL' &gt;&gt; /etc/rc.d/init.d/postfix
echo '}' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'stop() {' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        # Stop daemons.' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        echo -n $"Shutting down postfix: "' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        /usr/sbin/postfix stop 2&gt;/dev/null 1&gt;&amp;2 &amp;&amp; success || failure $"postfix stop"' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        RETVAL=$?' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        [ $RETVAL -eq 0 ] &amp;&amp; rm -f /var/lock/subsys/postfix' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        echo' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        return $RETVAL' &gt;&gt; /etc/rc.d/init.d/postfix
echo '}' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'reload() {' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        echo -n $"Reloading postfix: "' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        /usr/sbin/postfix reload 2&gt;/dev/null 1&gt;&amp;2 &amp;&amp; success || failure $"postfix reload"' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        RETVAL=$?' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        echo' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        return $RETVAL' &gt;&gt; /etc/rc.d/init.d/postfix
echo '}' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'abort() {' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        /usr/sbin/postfix abort 2&gt;/dev/null 1&gt;&amp;2 &amp;&amp; success || failure $"postfix abort"' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        return $?' &gt;&gt; /etc/rc.d/init.d/postfix
echo '}' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'flush() {' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        /usr/sbin/postfix flush 2&gt;/dev/null 1&gt;&amp;2 &amp;&amp; success || failure $"postfix flush"' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        return $?' &gt;&gt; /etc/rc.d/init.d/postfix
echo '}' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'check() {' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        /usr/sbin/postfix check 2&gt;/dev/null 1&gt;&amp;2 &amp;&amp; success || failure $"postfix check"' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        return $?' &gt;&gt; /etc/rc.d/init.d/postfix
echo '}' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'restart() {' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        stop' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        start' &gt;&gt; /etc/rc.d/init.d/postfix
echo '}' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo '# See how we were called.' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'case "$1" in' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  start)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        start' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  stop)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        stop' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  restart)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        stop' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        start' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  reload)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        reload' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  abort)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        abort' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  flush)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        flush' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  check)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        check' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  status)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        status master' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  condrestart)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        [ -f /var/lock/subsys/postfix ] &amp;&amp; restart || :' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        ;;' &gt;&gt; /etc/rc.d/init.d/postfix
echo '  *)' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        echo $"Usage: postfix {start|stop|restart|reload|abort|flush|check|status|condrestart}"' &gt;&gt; /etc/rc.d/init.d/postfix
echo '        exit 1' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'esac' &gt;&gt; /etc/rc.d/init.d/postfix
echo ' ' &gt;&gt; /etc/rc.d/init.d/postfix
echo 'exit $?' &gt;&gt; /etc/rc.d/init.d/postfix</pre>
<pre>chmod 744 /etc/rc.d/init.d/postfix
chkconfig --add postfix</pre>
</blockquote>
<p>Create the vmail tree</p>
<blockquote>
<pre>mkdir /var/vmail
chown vmail.vmail /var/vmail</pre>
</blockquote>
<p>Tweak the aliases file. These mappings are used for system related mails eg  crontab messages, postfix bounces etc. &lt;username@mail.<font color="#ff0000">yourdomain.com</font>&gt;</p>
<blockquote>
<pre>vi /etc/aliases</pre>
<blockquote>
<pre>root:    someone@<font color="#ff0000">yourdomain.com</font></pre>
</blockquote>
<pre>newaliases</pre>
</blockquote>
<p>Try starting Postfix</p>
<blockquote>
<pre>/etc/rc.d/init.d/postfix start</pre>
<p>If all goes well, you should be able to run &#8220;ps axf&#8221; see something like :</p>
<blockquote>
<pre>7184 ? Ss 0:00 /usr/libexec/postfix/master
7185 ? S 0:00   \_ pickup -l -t fifo -u
7186 ? S 0:00   \_ qmgr -l -t fifo -u</pre>
</blockquote>
<p>Also, you should take a look in the maillog file to see if any errors are    being reported there</p>
<blockquote>
<pre>tail -f /var/log/maillog</pre>
</blockquote>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Disable  logwatch script from reporting on Postfix logs</p>
<blockquote><p>The logwatch script runs nightly, and emails a report to the root user  	Unless your server is very low volume, I would recommend you tell logwatch  	not to report postfix stats, otherwise the report gets much too big</p>
<pre>vi /etc/log.d/conf/logwatch.conf</pre>
<blockquote>
<pre># Look for where it says "Service = All" and underneath that add this line :
Service = -postfix</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="INSTALL_A_2ND_ETHERNET_IP"></a>INSTALL A 2ND ETHERNET IP</h3>
<p>We want to have a 2nd IP address so that we can keep our MX-traffic separate  from our customer-SMTP traffic</p>
<p>Customers will use the &#8220;mail.<font color="#ff0000">yourdomain.com</font>&#8221; (192.168.1.10) name in their  mail client&#8217;s SMTP server settings, but in our zone files we will point the  primary MX records to a different hostname such as &#8220;mail-mx.<font color="#ff0000">yourdomain.com</font>&#8221;  (192.168.1.11)</p>
<p>Having two interfaces allows us to set the Postfix MX concurrency to  something sensibly low (to prevent a spam influx from overloading our server),  while at the same time we can retain a high concurrency on the customer-SMTP  settings so that our users don&#8217;t ever see a connection-refused error</p>
<p>Let&#8217;s assume our network interface is eth0. Then there is a file /etc/sysconfig/network-scripts/ifcfg-eth0  which looks like this:</p>
<blockquote>
<pre>DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.1.255
IPADDR=192.168.1.10
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
TYPE=Ethernet</pre>
</blockquote>
<p>Now we want to create the virtual interface eth0:0 with the IP address  192.168.0.101. All we have to do is to create the file /etc/sysconfig/network-scripts/ifcfg-eth0:0  which looks like this:</p>
<blockquote>
<pre>DEVICE=eth0:0
BOOTPROTO=static
BROADCAST=192.168.1.255
IPADDR=192.168.1.11
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
TYPE=Ethernet</pre>
</blockquote>
<p>Once that has been done, you have to restart the network for the changes to  take effect</p>
<blockquote>
<pre>/etc/rc.d/init.d/network restart</pre>
</blockquote>
<p>If you then run ifconfig, you should see something like this :</p>
<blockquote>
<pre>eth0 Link encap:Ethernet HWaddr 00:07:E9:4B:AD:83
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:28442 errors:0 dropped:0 overruns:0 frame:0
TX packets:28385 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14081755 (13.4 MiB) TX bytes:4847753 (4.6 MiB)

eth0:0 Link encap:Ethernet HWaddr 00:07:E9:4B:AD:83
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:30 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2190 (2.1 KiB) TX bytes:2190 (2.1 KiB)</pre>
</blockquote>
<p>Tell Postfix which IP does what :</p>
<blockquote><p>vi /etc/postfix/master.cf</p>
<blockquote><p># Change this :</p>
<blockquote>
<pre>smtp inet n - n - - smtpd</pre>
</blockquote>
<p># to this :</p>
<blockquote>
<pre>127.0.0.1:smtp    inet n - n - 10 smtpd
192.168.1.10:smtp inet n - n - 100 smtpd
192.168.1.11:smtp inet n - n - 50  smtpd-mx
   -o smtpd_sasl_auth_enable=no</pre>
</blockquote>
</blockquote>
<pre>cd /usr/libexec/postfix
ln -s smtpd smtpd-mx</pre>
</blockquote>
<p>Notes :</p>
<blockquote><p>Our MX concurrency has been set to a lower value (50) than our  customer-SMTP concurrency (100). You can tweak the these values up/down  	(particularly the MX concurrency) to suit your  server&#8217;s power / load. 	<img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />For a  	small server I would recommend the SMTP-MX concurrency be set to something  	like 25. For a medium server you can set it to something like 50, for a  	large server you will need to use 100+.</p>
<p>We have created a new application-name called smtpd-mx. This is  just a cosmetic tweak, so that  when you are running commands like pstree, you can easily see exactly how many sessions  of MX and customer-SMTP you have running <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />For the  	smtpd-mx service, we have used a configuration option to disable SASL (  	SMTP-AUTH ). In most scenarios, there is no need to have SMTP-AUTH enabled  	for MX traffic &#8211; disabling it will save some resources.</p>
<p>Also note that you might like to add additional IPs to the server as well  (eth0:1 eth0:2 etc), one for each virtual domain you host. As this opens up  options for other config tweaks which will be discussed later in this document.  Eg setting a default <a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEFAULT_IMAP_POP3_DOMAIN_PER_HOSTNAME">pop3/imap</a> 	<a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEFAULT_SMTP-AUTH_DOMAIN_PER_HOSTNAME">smtp-auth</a> 	<a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEFAULT_PURE-FTPD_DOMAIN_PER_HOSTNAME">ftp</a> 	<a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#DEFAULT_SQWEBMAIL_DOMAIN_PER_HOSTNAME">sqwebmail</a> domain per  hostname, and also <a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#HOSTING_MULTIPLE_SSL_DOMAINS_FOR_POSTFIX">allowing Postfix to attach one SSL cert per hostname</a>.</p></blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Add entries  to your reverse DNS</p>
<blockquote><p>For each IP address, you need to make sure you have added a reverse DNS  	entry. If you fail to do this you might find your server is blocked by some  	mail servers. eg :</p>
<blockquote>
<pre>$ORIGIN 1.168.192.in-addr.arpa.
10	PTR	mail.<font color="#ff0000">yourdomain.com</font>.
11	PTR	mail-mx.<font color="#ff0000">yourdomain.com</font>.</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="SQLGREY_GREYLISTING"></a>SQLGREY GREYLISTING</h3>
<p><a href="http://sqlgrey.sourceforge.net/">http://sqlgrey.sourceforge.net/</a></p>
<p>Greylisting provides excellent protection against spammers, at the expense of  slightly delaying some mail deliveries</p>
<p>Install the prerequisite Perl modules</p>
<blockquote>
<pre>perl -MCPAN -e shell</pre>
<blockquote>
<pre># press enter through all the questions until you come to the region selections
# At that point you will need to choose your preferred mirrors</pre>
<pre>o conf prerequisites_policy follow
install MD5 LWP Net::Server IO::Multiplex DBD::mysql</pre>
<pre>quit</pre>
</blockquote>
</blockquote>
<p>Create the user account</p>
<blockquote>
<pre>groupadd sqlgrey
useradd -r -m -g sqlgrey sqlgrey</pre>
</blockquote>
<p>Download and unpack the sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/sqlgrey/sqlgrey-1.6.7.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/sqlgrey/sqlgrey-1.6.7.tar.bz2</a>
tar xjf sqlgrey-1.6.7.tar.bz2
chown -R root.root sqlgrey-1.6.7
cd sqlgrey-1.6.7</pre>
</blockquote>
<p>Create the MySQL database</p>
<blockquote>
<pre>mysql</pre>
<blockquote>
<pre>CREATE DATABASE sqlgrey;
GRANT ALL ON sqlgrey.* to sqlgrey@localhost;
quit</pre>
</blockquote>
</blockquote>
<blockquote><p>( SQLgrey program will auto create its tables for us on startup )</p></blockquote>
<p>Install the binaries and config files</p>
<blockquote>
<pre>make install</pre>
<pre># installed to /usr/sbin by default, I prefer to have them in /usr/local/sbin
mv /usr/sbin/sqlgrey /usr/local/sbin
mv /usr/sbin/update_sqlgrey_config /usr/local/sbin
mv /usr/bin/sqlgrey-logstats.pl /usr/local/sbin</pre>
<pre># create the files that can be used for storing local whitelist entries
touch /etc/sqlgrey/clients_ip_whitelist.local
touch /etc/sqlgrey/clients_fqdn_whitelist.local</pre>
</blockquote>
<p>Make the following changes to the config file</p>
<blockquote>
<pre>vi /etc/sqlgrey/sqlgrey.conf</pre>
<blockquote>
<pre>reconnect_delay = 1</pre>
<pre>awl_age = 32
group_domain_level = 10</pre>
<pre>db_type = mysql</pre>
<pre>optmethod = optout</pre>
<pre>admin_mail = someadmin@<font color="#ff0000">yourdomain.com</font></pre>
</blockquote>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />TIP : If  	your are building a big/busy server you might like to reduce the amount of  	logging generated by sqlgrey by adjusting these settings :</p>
<blockquote>
<blockquote>
<pre>loglevel = 1
log_override = conf:2</pre>
</blockquote>
</blockquote>
<p>Install the init script</p>
<blockquote>
<pre>cp init/sqlgrey /etc/rc.d/init.d/sqlgrey</pre>
<pre>vi /etc/rc.d/init.d/sqlgrey</pre>
<blockquote>
<pre>#go to the start section, and change the sqlgrey -d command to include the full path
/usr/local/sbin/sqlgrey -d</pre>
<pre>#go to the stop section, and change the sqlgrey -k command to include the full path
/usr/local/sbin/sqlgrey -k</pre>
</blockquote>
<pre>chkconfig --add sqlgrey
chkconfig sqlgrey on</pre>
</blockquote>
<p>Start the program</p>
<blockquote>
<pre>/etc/rc.d/init.d/sqlgrey start</pre>
<p>If all goes well, ps axf should should show you something like this :</p>
<blockquote>
<pre>1898 ? Ss 0:00 /usr/bin/perl -w /usr/local/sbin/sqlgrey -d</pre>
</blockquote>
</blockquote>
<p>Tweak the Postfix config, so incoming external mail gets routed via the    greylisting daemon. ( You need to add the line shown in bold text )</p>
<blockquote>
<pre>vi /etc/postfix/main.cf</pre>
<blockquote>
<pre>reject_rbl_client list.dsbl.org,
reject_rbl_client sbl-xbl.spamhaus.org,
<strong>check_policy_service inet:127.0.0.1:2501,
</strong>permit</pre>
</blockquote>
<pre>postfix reload</pre>
</blockquote>
<p>Setup auto-downloading of rules. These will be stored into the    clients_ip_whitelist and clients_fqdn_whitelist files.</p>
<blockquote>
<pre>crontab -e</pre>
<blockquote>
<pre># download sqlgrey rules
0 0 * * * /usr/local/sbin/update_sqlgrey_config</pre>
</blockquote>
</blockquote>
<p>For your local users who want to opt-out of the greylisting, you simply add    their email address to the optout_email table :</p>
<blockquote>
<pre>mysql</pre>
<blockquote>
<pre>USE sqlgrey;
-- this user wants to opt out
INSERT INTO optout_email (email) VALUES ('someuser@somedomain.com');
-- all users on this domain want to opt out
INSERT INTO optout_domain (domain) VALUES ('somedomainother.com');
quit</pre>
</blockquote>
</blockquote>
<p>To reduce the load on your database server, you can put the most common hosts into the    clients_ip_whitelist.local files. You can use sqlgrey-logstats.pl tool to    extract this info from your logs.</p>
<p>If you have got secondary MX servers setup for your domain, you need to    install SQLgrey on the secondary MX machines as well. Don&#8217;t forget to put the    secondary MX server IP&#8217;s into the primary MX&#8217;s clients_ip_whitelist.local    file.</p>
<p>eg :</p>
<blockquote>
<pre>echo "*.<font color="#ff0000">yourdomain.com</font>" &gt; /etc/sqlgrey/clients_fqdn_whitelist.local
echo "192.168"        &gt; /etc/sqlgrey/clients_ip_whitelist.local</pre>
</blockquote>
<hr />
<h3><a name="COURIER-AUTHLIB"></a>COURIER-AUTHLIB</h3>
<p>Courier-authlib provides user authentication services to Courier-IMAP,  Courier-POP3d, and SqWebMail</p>
<p>Install the prerequisites</p>
<blockquote>
<pre>yum install expect</pre>
<pre># This next one isnt used by authlib, but are used by several of the other courier tools
# like maildrop and Courier-IMAP
yum install gamin-devel</pre>
</blockquote>
<p>Download and unpack the sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.59.3.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.59.3.tar.bz2</a></pre>
<pre>tar xjf courier-authlib-0.59.3.tar.bz2
chown -R root.root courier-authlib-0.59.3
cd courier-authlib-0.59.3</pre>
</blockquote>
<p>Configure, compile, install</p>
<blockquote>
<pre>./configure \
  --prefix=/usr/local/courier-authlib \
  --without-ipv6 \
  --disable-root-check \
  --without-authpwd \
  --without-authshadow \
  --without-authuserdb \
  --without-authpgsql \
  --without-authldap \
  --without-authvchkpw \
  --without-authcustom \
  --without-authpam \
  --without-authpipe \
  --with-authmysql \
  --with-authdaemon \
  --with-redhat</pre>
<pre>make
make check
make install
make install-configure</pre>
</blockquote>
<p>Tweak the config file so that courier-authlib can access the info from our  database</p>
<blockquote>
<pre>vi /usr/local/courier-authlib/etc/authlib/authmysqlrc</pre>
<blockquote>
<pre>MYSQL_SERVER localhost
MYSQL_USERNAME postfixuser
MYSQL_PASSWORD postfixpass
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_PORT 0
MYSQL_OPT 0
MYSQL_DATABASE postfix
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_CLEAR_PWFIELD clear_password
#you can optionally enable this next setting if you want a particular domain to be appended
#when users haven't specified a domain during authentication
#DEFAULT_DOMAIN <font color="#ff0000">yourdomain.com  </font>
MYSQL_UID_FIELD '1001'
MYSQL_GID_FIELD '1001'
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD '/var/vmail'
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD CONCAT(maildir,"Maildir/")
MYSQL_QUOTA_FIELD CONCAT(mailquota*1024*1024,"S")
MYSQL_AUXOPTIONS_FIELD CONCAT("disableimap=",disableimap,",disablepop3=",disablepop3,",disablewebmail=",disablewebmail)
MYSQL_WHERE_CLAUSE active='1'</pre>
</blockquote>
</blockquote>
<p>Tweak the config to disable some unneeded features</p>
<blockquote>
<pre>vi /usr/local/courier-authlib/etc/authlib/authdaemonrc</pre>
<blockquote>
<pre>#if your server is going to be very busy, you might need to increase this one
daemons=5</pre>
<pre># Disable some unneeded functionality.
# (Note that these could optionally be re-enabled per-user by adding appropriate columns to the mailbox database)
#
#   wbnochangepass : In our case the postfix MySQL database will be maintained by our billing system, so although
#                    sqwebmail has functionality to allow users to can change their passwords, these changes would
#                    be overwritten by the billing system... So we will turn that option off
#   wbusexsender   : Include an X-Sender header to all outgoing mail ( allows you to track actual sender, even if
#                    user has altered their From address in sqwebmail )
#   disableshared  : We don't want shared folders, as this mail server is going to be used in ISP rather than corporate scenario
#   webnodsn       : Hide the option "<label for="dsn">Request delivery confirmation receipt" from the SQWebmail compose  new message screen
#                  : People expect this to be a read receipt ( RFC2298 ) but its actually a delivery reciept (RFC3464 )
#                  : End users find this confusing, better to remove it and save on your helpdesk calls</label>

DEFAULTOPTIONS="wbnochangepass=1,wbusexsender=1,disableshared=1,wbnodsn=1"</pre>
</blockquote>
</blockquote>
<p>Install the init script</p>
<blockquote>
<pre>cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
chmod 744 /etc/rc.d/init.d/courier-authlib
chkconfig --add courier-authlib</pre>
</blockquote>
<p>Start the daemon</p>
<blockquote>
<pre>/etc/rc.d/init.d/courier-authlib start</pre>
<p>ps axf should give something like this :</p>
<blockquote>
<pre>1515 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/usr/local/courier-authlib/var/spool/authdaemon/pid -s
1516 ? S 0:00  \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
1517 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
1518 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
1519 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
1520 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
1521 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond</pre>
</blockquote>
</blockquote>
<p>TROUBLESHOOTING TIP :</p>
<blockquote><p>Courier-authlib includes a couple of debugging tools. These can be handy if    you are having problems eg auth&#8217;ing via POP3, but aren&#8217;t sure if its your POP3    config that&#8217;s broken or whether its actually the courier-authlib that&#8217;s not    working properly.</p>
<p><font size="3"></p>
<pre># display all accounts
/usr/local/courier-authlib/sbin/authenumerate</pre>
<pre># perform a test authentication, and show all values returned from courier-authlib
/usr/local/courier-authlib/sbin/authtest someuser@yourdomain.com somepassword</pre>
<p></font></p></blockquote>
<hr />
<h3><a name="MAILDROP"></a>MAILDROP</h3>
<p>Maildrop provides Postfix with a Maildir++ softquota-compatible way to  deliver mail into user&#8217;s mailboxes.</p>
<p>Note : Instead of using maildrop, many people use the &#8220;<a href="http://web.onda.com.br/nadal/">Postfix  VDA</a>&#8221; patch instead. This patch hacks the Postfix virtual delivery agent to  (supposedly) support Maildir++ softquotas. However I would strongly recommend  you <strong>don&#8217;t use that patch!</strong> The doco etc for the patch makes it sounds like it does everything you need. However when you actually inspect the code it is a total debacle zone. There are numerous logic errors &#8211; the patch fails to follow the Maildir++ specs, and will cause a ridiculous amount of needless load on your server. Maildrop does everything correctly, doesn&#8217;t require the Postfix source code to be patched ( which is good for Postfix&#8217;s security/reliability ), and gives additional features like quota warnings. Maildrop also has the huge bonus of being from the same author as Courier-imap/pop3d/sqwebmail so you are guaranteed excellent interoperability between all your tools that touch the Maildir</p>
<p>Download and unpack the sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/maildrop-2.0.4.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/maildrop-2.0.4.tar.bz2</a></pre>
<pre>tar xjf maildrop-2.0.4.tar.bz2
chown -R root.root maildrop-2.0.4
cd maildrop-2.0.4</pre>
</blockquote>
<p>Configure, compile, install</p>
<blockquote>
<pre>COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig \
CPPFLAGS=-I/usr/local/courier-authlib/include \
./configure \
  --enable-smallmsg=262144 \
  --enable-maildirquota</pre>
<pre>make
make install-strip
make install-man</pre>
</blockquote>
<p>TIP: if you read the Maildrop  docs, there is a configure option &#8220;&#8211;without-db&#8221; which sounds quite desirable.  However its not a good idea to use that option because it will prevent some of  the Maildrop autoresponder functionality from working properly.</p>
<p>Configure maildrop binary to have siud root. It needs root permissions to be  able to connect to the Courier-authlib socket. It drops root permissions as soon  as it determines the final account user and group id. ( You cant just go and  grant world permissions on the socket, as this would allow anyone on the system  to obtain any account&#8217;s password ).</p>
<blockquote>
<pre>chmod u+s /usr/local/bin/maildrop</pre>
</blockquote>
<p>Setup automatic quota warnings</p>
<blockquote><p>When you use the -w option with maildrop, it enables the sending of quota    warning messages. The warning message is copied verbatim from /usr/local/etc/quotawarnmsg    with the addition of the &#8220;Date:&#8221; and &#8220;Message-Id:&#8221; headers. The warning is    repeated every 24 hours (at least), until the Maildir drops below X percent    full.</p>
<pre>cp maildir/quotawarnmsg /usr/local/etc</pre>
<pre>vi /usr/local/etc/quotawarnmsg</pre>
<blockquote>
<pre># tweak wording to suit your needs</pre>
</blockquote>
<pre>vi /etc/postfix/master.cf</pre>
<blockquote>
<pre><span class="quote">#</span> Maildrop will use courier-authlib to lookup account data for the user specified in the -d option<span class="quote">.
#
# <img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />The example here tells Postfix to launch a maximum of 10 simultaneous mailbox processes.
# You might need to tweak this depending on how busy your server is. A higher number will
# tell Postfix to try to deliver more messages per second, but setting the value too high can
# cause problems if you run out of disk I/O. I would recommend setting this concurrency value
# to 5 for a small server, 10 for medium, and 20 for large.
#
maildrop unix - n n - 10 pipe
  flags=DRhu user=vmail argv=/usr/local/bin/maildrop <strong>-w 80</strong> -d ${recipient} </span></pre>
</blockquote>
<pre><span class="quote">postfix reload</span></pre>
</blockquote>
<p>Optionally can configure some global maildrop rules</p>
<blockquote>
<pre><span class="quote">vi /etc/maildroprc</span></pre>
<blockquote>
<pre># You can uncomment this next line if you want some debugging output.
# Useful if you are doing some tweaking to try and get mail deliveries to follow
# some more sophisticated rulesets.
#
#logfile "/var/log/maildroprc.log"</pre>
<pre># Per-user .mailfilter files are installed (eg by sqwebmail) into the user's home dir
# at /var/vmail/yourdomain.com/u/user1/.mailfilter
#
# When maildrop runs, it is coded to look for any global rules in : /etc/maildroprc
# and then next will look for any per-user rules in : $HOME/.mailfilter
#
# However, with a vmail style config we have a problem...  $HOME doesn't point to a
# per-user location. On a machine with all the accounts in /etc/passwd, $HOME would
# point to the right place, but vmail systems are different because they host all the
# mailboxes  under a single UID.
#
# When postfix calls maildrop to perform a message delivery,
# $HOME will contain the vmail home : /var/vmail
# $DEFAULT will contain the path to the maildir eg : yourdomain.com/u/user1/Maildir
#
# So to allow us to still run per-user rules, we will add an INCLUDE command in
# the global file so that we can still pick up any per-user filtering rules.
#</pre>
<pre># if the user has a .mailfilter file, then execute it's contents now
exception {
    include "$HOME/$DEFAULT/../.mailfilter"
}</pre>
</blockquote>
</blockquote>
<p>TIP : If you need to do      some debugging of maildrop you can run it from the command prompt with      verbose logging enabled. This will identify if its talking to the database      successfully, and will also show up if there are permissions problems etc on      the destination dir  :</p>
<blockquote>
<pre>[root@mail01 ~]# maildrop -V9 -d someone@<font color="#ff0000">yourdomain.com</font>
maildrop: authlib: groupid=1001
maildrop: authlib: userid=1001
maildrop: authlib: logname=someone@<font color="#ff0000">yourdomain.com</font>, home=/var/vmail, mail=<font color="#ff0000">yourdomain.com</font>/s/someone/Maildir/
maildrop: Changing to /var/vmail</pre>
<pre>&lt;press CTRL-D here&gt;</pre>
</blockquote>
<hr />
<h3><a name="COURIER-IMAP_/_COURIER-POP3D"></a>COURIER-IMAP / COURIER-POP3D</h3>
<p><a href="http://www.courier-mta.org/imap/">http://www.courier-mta.org/imap/</a></p>
<p>Download and unpack the sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.3.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.3.tar.bz2</a></pre>
<pre>tar xjf courier-imap-4.1.3.tar.bz2
chown -R root.root courier-imap-4.1.3
cd courier-imap-4.1.3</pre>
</blockquote>
<p>Configure, compile, install the program</p>
<blockquote>
<pre>COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig \
CPPFLAGS=-I/usr/local/courier-authlib/include \
./configure \
  --without-ipv6 \
  --prefix=/usr/local/courier-imap \
  --disable-root-check \
  --with-redhat</pre>
<pre>make
make install
make install-configure</pre>
</blockquote>
<p>Appropriately tweak the config files</p>
<blockquote>
<pre>vi /usr/local/courier-imap/etc/imapd</pre>
<blockquote>
<pre># If you are going to run a busy IMAP-based webmail package, you will need to substantially increase this.
# The default value of 4 is insufficient even for servicing individual users, since clients like Thunderbird default to using up to 5 simultaneous connections
#
MAXPERIP=20</pre>
<pre># Add our collection of supported auth methods to the advertised capability string
IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA <strong>AUTH=CRAM-MD5 AUTH=CRAM-SHA1 AUTH=PLAIN AUTH=LOGIN </strong>IDLE"</pre>
<pre># we want to turn off the announcement of IMAP ACL extensions, as we dont need this ( we arent using shared folders ),
# and the ACL stuff makes Thunderbird spit errors in some cases
IMAP_ACL=0</pre>
<pre>IMAP_CAPABILITY_TLS="$IMAP_CAPABILITY"</pre>
<pre># Enabled the enhanced IDLE functionality
# This allows the IMAP server to notify your client when something has changed (eg a new message has arrived)
IMAP_ENHANCEDIDLE=1</pre>
<pre># If you were going to have mainly Outlook Express based IMAP users, you can tell Courier-IMAP to name the trash folder "Deleted Items"
# However in our case we are expecting most IMAP users to be webmail, so sticking with the default "Trash" foldername is probably best.
#IMAP_TRASHFOLDERNAME="Deleted Items"
#IMAP_EMPTYTRASH="Deleted Items":7</pre>
<pre># Enable the Courier-IMAP daemon
IMAPDSTART=YES</pre>
</blockquote>
<pre>vi /usr/local/courier-imap/etc/imapd-ssl</pre>
<blockquote>
<pre># enable courier-imaps (port 993) daemon
IMAPDSSLSTART=YES</pre>
<pre># enable STARTTLS extensions for IMAP. Enabling this means "STARTTLS" will be added to the IMAP CAPABILITY line
IMAPDSTARTTLS=YES</pre>
<pre># nominate where the SSL key/certificate can be found
TLS_CERTFILE=/usr/local/ssl/mail.<font color="#ff0000">yourdomain.com</font>.pem</pre>
</blockquote>
<pre>vi /usr/local/courier-imap/etc/pop3d</pre>
<blockquote>
<pre># you would likely have to increase this for a busy server
MAXDAEMONS=40</pre>
<pre># Add out collection of supported auth methods to the advertised capability string
POP3AUTH="CRAM-MD5 CRAM-SHA1 PLAIN LOGIN"</pre>
<pre>POP3AUTH_TLS="$POP3AUTH"</pre>
<pre># enabled the courier-pop3 daemon
POP3DSTART=YES</pre>
</blockquote>
<pre>vi /usr/local/courier-imap/etc/pop3d-ssl</pre>
<blockquote>
<pre># enable the courier-pop3s (port 995) daemon
POP3DSSLSTART=YES</pre>
<pre># enable STARTTLS extensions for POP3.
POP3_STARTTLS=YES</pre>
<pre># nominate where the SSL key/certificate can be found
TLS_CERTFILE=/usr/local/ssl/mail.<font color="#ff0000">yourdomain.com</font>.pem</pre>
</blockquote>
</blockquote>
<p>Setup the init script</p>
<blockquote>
<pre>cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imap
chmod 744 /etc/rc.d/init.d/courier-imap
chkconfig --add courier-imap</pre>
</blockquote>
<p>Create an empty shared folder index file, to prevent Courier-IMAP from  complaining to syslog about it being missing. We aren&#8217;t using shared folders at  all on this server.</p>
<blockquote>
<pre>touch /usr/local/courier-imap/etc/shared/index</pre>
</blockquote>
<p>Start the daemons</p>
<blockquote>
<pre>/etc/rc.d/init.d/courier-imap start</pre>
<p>ps axf should give something like this</p>
<blockquote>
<pre>14611 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/var/run/imapd.pid -start -name=imapd /usr/local/couri
14612 ? S 0:00  \_ /usr/local/courier-imap/libexec/couriertcpd -address=0 -maxprocs=40 -maxperip=4 -nodnslookup -noident
14618 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/var/run/imapd-ssl.pid -start -name=imapd-ssl /usr/loc
14619 ? S 0:00  \_ /usr/local/courier-imap/libexec/couriertcpd -address=0 -maxprocs=40 -maxperip=4 -nodnslookup -noident
14624 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/var/run/pop3d.pid -start -name=pop3d /usr/local/couri
14625 ? S 0:00  \_ /usr/local/courier-imap/libexec/couriertcpd -address=0 -maxprocs=40 -maxperip=4 -nodnslookup -noident
14630 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/var/run/pop3d-ssl.pid -start -name=pop3d-ssl /usr/loc
14631 ? S 0:00  \_ /usr/local/courier-imap/libexec/couriertcpd -address=0 -maxprocs=40 -maxperip=4 -nodnslookup -noident[</pre>
</blockquote>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Disable  logwatch script from reporting on imap logs</p>
<blockquote><p>The logwatch script runs nightly, and emails a report to the root user.  	Unless your server is very low volume, I would recommend you tell logwatch  	not to report imap stats, otherwise the report gets much too big</p>
<pre>vi /etc/log.d/conf/logwatch.conf</pre>
<blockquote>
<pre># Look for where it says "Service = All" and underneath that add this line :
Service = -imapd</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="APACHE"></a>APACHE</h3>
<p>Create some directory structure</p>
<blockquote>
<pre>mkdir -p /var/www/mail/html
mkdir /var/www/mail/cgi-bin
mkdir /var/www/mail/logs</pre>
</blockquote>
<p>Remark out the following  modules, which are part of the standard Apache installation, but we wont need.  This will reduce the bulk of Apache, and in my experience will make it more  stable</p>
<blockquote>
<pre>vi /etc/httpd/conf/httpd.conf</pre>
<blockquote>
<pre>#LoadModule auth_anon_module modules/mod_auth_anon.so
#LoadModule auth_dbm_module modules/mod_auth_dbm.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule auth_ldap_module modules/mod_auth_ldap.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule status_module modules/mod_status.so
#LoadModule asis_module modules/mod_asis.so
#LoadModule info_module modules/mod_info.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule disk_cache_module modules/mod_disk_cache.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule mem_cache_module modules/mod_mem_cache.so</pre>
</blockquote>
</blockquote>
<p>Add these commands to the bottom of the file so that Apache can serve sqwebmail pages</p>
<blockquote>
<pre>vi /etc/httpd/conf/httpd.conf</pre>
<blockquote>
<pre>LogFormat "%v %h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_vhost</pre>
<pre>NameVirtualHost *:80</pre>
<pre>&lt;VirtualHost *:80&gt;</pre>
<pre>    # The first vhost entry is used if no hostname matches are found amongst other vhost entries.
    # So lets pop a "default" entry here to send any such requests through to our corporate webpage
    ServerAdmin webmaster@<font color="#ff0000">yourdomain.com</font>
    DocumentRoot /var/www/mail/html
    ServerName placeholder-for-no-vhost-match
    ErrorLog /var/www/mail/logs/error_log
    CustomLog /var/www/mail/logs/access_log combined_vhost
    RewriteEngine On
    RewriteRule .* http://www.<font color="#ff0000">yourdomain.com</font>/ [R,L]</pre>
<pre>&lt;/VirtualHost&gt;</pre>
<pre>&lt;VirtualHost *:80&gt;</pre>
<pre>    ServerAdmin webmaster@<font color="#ff0000">yourdomain.com
    </font>DocumentRoot /var/www/mail/html
    ServerName mail.<font color="#ff0000">yourdomain.com</font>
    ServerAlias webmail.<font color="#ff0000">yourdomain.com
</font>    ServerAlias mail.hosteddomain1.com.au webmail.hosteddomain1.com
    ServerAlias mail.hosteddomain2.com.au webmail.hosteddomain2.com
    ServerAlias mail.hosteddomain3.com.au webmail.hosteddomain3.com
    ServerAlias mail.hosteddomain4.com.au webmail.hosteddomain4.com
    ServerAlias mail.hosteddomain5.com.au webmail.hosteddomain5.com</pre>
<pre>    ErrorLog /var/www/mail/logs/error_log
    CustomLog /var/www/mail/logs/access_log combined_vhost</pre>
<pre>    RewriteEngine on
    RewriteRule ^/index\.html$ http://%{HTTP_HOST}/cgi-bin/sqwebmail</pre>
<pre>    ScriptAlias /cgi-bin/ "/var/www/mail/cgi-bin/"</pre>
<pre>    &lt;Directory "/var/www/mail/cgi-bin"&gt;
	AllowOverride None
	Options None
	Order allow,deny
	Allow from all
    &lt;/Directory&gt;</pre>
<pre>    BrowserMatch "MSIE [45]" nokeepalive downgrade-1.0 force-response-1.0</pre>
<pre>&lt;/VirtualHost&gt;</pre>
<pre></pre>
</blockquote>
</blockquote>
<blockquote>
<pre>vi /etc/httpd/conf.d/ssl.conf</pre>
<blockquote>
<pre>&lt;VirtualHost _default_:443&gt;</pre>
<pre>    ServerAdmin postmaster@<font color="#ff0000">yourdomain.com
    </font>DocumentRoot /var/www/mail/html</pre>
<pre>    SSLCertificateFile /usr/local/ssl/mail.<font color="#ff0000">yourdomain.com</font>.crt
    SSLCertificateKeyFile /usr/local/ssl/mail.<font color="#ff0000">yourdomain.com</font>.key</pre>
<pre>    ErrorLog /var/www/mail/logs/ssl_error_log</pre>
<pre>    RewriteEngine On
    RewriteRule ^/index\.html$ http://mail.<font color="#ff0000">yourdomain.com</font>/cgi-bin/sqwebmail</pre>
<pre>    ScriptAlias /cgi-bin/ "/var/www/mail/cgi-bin/"</pre>
<pre>    &lt;Directory "/var/www/mail/cgi-bin"&gt;
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    &lt;/Directory&gt;</pre>
<pre>    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0</pre>
<pre>    CustomLog /var/www/mail/logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"</pre>
<pre>&lt;/VirtualHost&gt;</pre>
</blockquote>
</blockquote>
<p>Add some more directory structure to  allow us to serve user homepages</p>
<blockquote>
<pre>mkdir -p /var/www/users/html
mkdir /var/www/users/cgi-bin
mkdir /var/www/users/logs</pre>
</blockquote>
<p>Add these commands so Apache can serve user pages. I would suggest you put in 1 VirtualHost entry per  domain</p>
<blockquote>
<pre>vi /etc/httpd/conf/httpd.conf</pre>
<blockquote>
<pre>&lt;VirtualHost *:80&gt;</pre>
<pre>    ServerAdmin webmaster@<font color="#ff0000">yourdomain.com
    </font>DocumentRoot /var/www/users/html
    ServerName users.<font color="#ff0000">yourdomain.com</font>
    ServerAlias home.<font color="#ff0000">yourdomain.com</font></pre>
<pre>    ErrorLog /var/www/users/logs/error_log
    CustomLog /var/www/users/logs/access_log combined_vhost</pre>
<pre>    DirectoryIndex index.html index.htm default.html default.htm
    RewriteEngine on
    RewriteRule ^/~([\w-_\.])([\w-_\.]*)/?(.*)$ /var/vmail/<font color="#ff0000">yourdomain.com</font>/$1/$1$2/public_html/$3 [L]
    RewriteRule ^/index.html$ http://www.<font color="#ff0000">yourdomain.com</font></pre>
<pre>    php_flag Engine Off</pre>
<pre>    &lt;Directory /var/vmail/<font color="#ff0000">yourdomain.com</font>/*/*/public_html&gt;
      AllowOverride FileInfo AuthConfig Indexes Limit
      Options MultiViews Indexes IncludesNoExec
      Order allow,deny
      Allow from all
    &lt;/Directory&gt;</pre>
<pre>    ScriptAlias /cgi-bin/ "/var/www/users/cgi-bin/"
    &lt;Directory "/var/www/users/cgi-bin"&gt;
	AllowOverride None
	Options None
	Order allow,deny
	Allow from all
    &lt;/Directory&gt;</pre>
<pre>&lt;/VirtualHost&gt;</pre>
</blockquote>
</blockquote>
<p>Remove the default welcome page</p>
<blockquote><p><tt>vi /etc/httpd/conf.d/welcome.conf</tt></p>
<blockquote>
<pre>#&lt;LocationMatch "^/+$"&gt;
#Options -Indexes
#ErrorDocument 403 /error/noindex.html
#&lt;/LocationMatch&gt;</pre>
</blockquote>
</blockquote>
<p>Setup favicons</p>
<blockquote>
<pre>cd /var/www/mail/html
wget http://www.<font color="#ff0000">yourdomain.com</font>/favicon.ico</pre>
<pre>cd /var/www/users/html
wget http://www.<font color="#ff0000">yourdomain.com</font>/favicon.ico</pre>
</blockquote>
<p>Restart your apache :</p>
<blockquote>
<pre>/etc/rc.d/init.d/httpd restart</pre>
</blockquote>
<p>Setup log rotation for your httpd  logs</p>
<blockquote>
<pre>vi /etc/logrotate.d/httpd</pre>
<blockquote>
<pre># change line from this
/var/log/httpd/*log {
# to this
/var/log/httpd/*log /var/www/mail/logs/*log /var/www/users/logs/*log {</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="SQWEBMAIL"></a>SQWEBMAIL</h3>
<p><a href="http://www.courier-mta.org/sqwebmail/"> http://www.courier-mta.org/sqwebmail/</a></p>
<p>Create the directory structure which will receive the sqwebmail png images, binary,  and logs</p>
<blockquote>
<pre>mkdir -p /var/www/mail/html/images/sqwebmail
mkdir -p /var/www/mail/cgi-bin
mkdir -p /var/www/mail/logs</pre>
</blockquote>
<p>Create an advertising banner type script that will be used by the sqwebmail binary.  The banner is displayed at the bottom of every page.</p>
<blockquote>
<pre>echo '#!/bin/sh' &gt; /usr/local/bin/sqwebmail-banner.sh
echo '##' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo '## This progam is called by sqwebmail for each [#B#] tag in the html templates' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo '## The ARGV[0] will be the name of the html template that launched the call' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo '##' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo 'echo "&lt;center&gt;";' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo 'echo "&lt;hr&gt;";' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo 'echo "&lt;b&gt;<font color="#ff0000">SomeISP</font> support - call <font color="#ff0000">1300 xxx xxx</font>&lt;/b&gt;";' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo 'echo "&lt;/center&gt;";' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
chmod 755 /usr/local/bin/sqwebmail-banner.sh</pre>
</blockquote>
<p>Download and extract the sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/sqwebmail-5.1.6.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/sqwebmail-5.1.6.tar.bz2</a></pre>
<pre>tar xjf sqwebmail-5.1.6.tar.bz2
chown -R root.root sqwebmail-5.1.6
cd sqwebmail-5.1.6</pre>
</blockquote>
<p>Configure and compile</p>
<blockquote>
<pre>COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig \
CPPFLAGS=-I/usr/local/courier-authlib/include \
./configure \
  --prefix=/usr/local/sqwebmail \
  --disable-autorenamesent \
  --enable-cgibindir=/var/www/mail/cgi-bin/ \
  --enable-imagedir=/var/www/mail/html/images/sqwebmail/ \
  --enable-imageurl=/images/sqwebmail \
  --with-maxformargsize=17500000 \
  --with-maxmsgsize=18000000 \
  --enable-bannerprog=/usr/local/bin/sqwebmail-banner.sh</pre>
<pre>make
make install
make install-configure</pre>
</blockquote>
<p>Allow sqwebmail  users to use (maildrop) message filtering rules</p>
<blockquote>
<pre>vi /usr/local/sqwebmail/etc/maildirfilterconfig</pre>
<blockquote>
<pre>MAILDIRFILTER=../.mailfilter
MAILDIR=$HOME/$DEFAULT</pre>
</blockquote>
</blockquote>
<p>Configure sqwebmail to start at bootup <span style="background-color:#ffff00;">(NEED TO WRITE AN PROPER SYSV-STYLE INIT  SCRIPT)</span></p>
<blockquote>
<pre>vi /etc/rc.d/rc.local</pre>
<blockquote>
<pre>/usr/local/sqwebmail/libexec/sqwebmaild.rc start</pre>
</blockquote>
</blockquote>
<p>Start the sqwebmail</p>
<blockquote>
<pre>/usr/local/sqwebmail/libexec/sqwebmaild.rc start</pre>
<p>If all goes well, ps axf should give something like this</p>
<blockquote>
<pre>29727 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/usr/local/sqwebmail/var/run/sqwebmaild.pid -start /us
29728 ? S 0:00 \_ /usr/local/sqwebmail/libexec/sqwebmail/sqwebmaild
29730 ? S 0:00 /usr/local/sqwebmail/libexec/sqwebmail/sqwebmaild
29732 ? S 0:00 /usr/local/sqwebmail/libexec/sqwebmail/sqwebmaild
29734 ? S 0:00 /usr/local/sqwebmail/libexec/sqwebmail/sqwebmaild
29736 ? S 0:00 /usr/local/sqwebmail/libexec/sqwebmail/sqwebmaild
29738 ? S 0:00 /usr/local/sqwebmail/libexec/sqwebmail/sqwebmaild</pre>
</blockquote>
</blockquote>
<p>Sqwebmail has a cache, that requires old files to be zapped regularly</p>
<blockquote>
<pre>crontab -e</pre>
<blockquote>
<pre># Purge sqwebmail cache files once per hour
0 * * * * /usr/local/sqwebmail/share/sqwebmail/cleancache.pl</pre>
</blockquote>
</blockquote>
<p>Test access :</p>
<blockquote><p>http://mail.<font color="#ff0000">yourdomain.com</font>/<br />
or<br />
https://mail.<font color="#ff0000">yourdomain.com</font>/</p></blockquote>
<p>Customise the sqwebmail templates ( apply your own branding )</p>
<blockquote><p>The ones I tweak are :</p>
<blockquote>
<pre>/usr/local/sqwebmail/share/sqwebmail/html/en/loginform.inc.html
/var/www/mail/html/images/sqwebmail/sqwebmail.css</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="CLAM_ANTIVIRUS"></a>CLAM ANTIVIRUS</h3>
<p><a href="http://www.clamav.net/">http://www.clamav.net/</a></p>
<p>Install prerequisite modules</p>
<blockquote>
<pre>yum install bzip2-devel</pre>
</blockquote>
<p>Create the user/group for clamd to run under</p>
<blockquote>
<pre>groupadd -r clamav
useradd -r -g clamav -d /var/amavis -m -s /bin/false -c "Clam AntiVirus" clamav</pre>
</blockquote>
<p>Download and extract the sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/clamav/clamav-0.90.2.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/clamav/clamav-0.90.2.tar.gz</a></pre>
<pre>tar xzf clamav-0.90.2.tar.gz
chown -R root.root clamav-0.90.2
cd clamav-0.90.2</pre>
</blockquote>
<p>Configure and compile</p>
<blockquote>
<pre>./configure</pre>
<pre># TIP: on some platforms (Incl CentOS) you may have to use
# ./configure --disable-zlib-vcheck</pre>
<pre>make
make install</pre>
<pre># This next step is recommended by ClamAV authors after installing 0.90.1
ldconfig</pre>
</blockquote>
<p>Tweak the config files as shown below</p>
<blockquote>
<pre>ln -s /usr/local/etc/clamd.conf /etc/clamd.conf
vi /etc/clamd.conf</pre>
<blockquote>
<pre># Example
LogSyslog yes
LocalSocket /var/amavis/clamd.sock
FixStaleSocket yes
MaxThreads 10
User clamav</pre>
</blockquote>
<pre>ln -s /usr/local/etc/freshclam.conf /etc/freshclam.conf
vi /etc/freshclam.conf</pre>
<blockquote>
<pre># Example
LogSyslog yes
DatabaseMirror db.<font color="#ff0000">au</font>.clamav.net
NotifyClamd /etc/clamd.conf</pre>
</blockquote>
</blockquote>
<p>Setup the init scripts</p>
<blockquote>
<pre>cp contrib/init/RedHat/clamd /etc/rc.d/init.d/clamd
chmod 744 /etc/rc.d/init.d/clamd
chkconfig --add clamd</pre>
<pre>vi /etc/rc.d/rc.local</pre>
<blockquote>
<pre>/usr/local/bin/freshclam -d</pre>
</blockquote>
</blockquote>
<p>Start the daemons</p>
<blockquote>
<pre>/etc/rc.d/init.d/clamd start
/usr/local/bin/freshclam -d</pre>
<p>ps axf should give something like this :</p>
<blockquote>
<pre>11139 ? Ss 0:00 /usr/local/sbin/clamd
11142 ? Ss 0:00 /usr/local/bin/freshclam -d</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="SPAMASSASSIN"></a>SPAMASSASSIN</h3>
<p><a href="http://spamassassin.apache.org/">http://spamassassin.apache.org/</a></p>
<p>Install the prerequisite perl modules</p>
<blockquote>
<pre>perl -MCPAN -e shell</pre>
<blockquote>
<pre>o conf prerequisites_policy follow
install LWP MD5
install Digest::SHA1 HTML::Parser Net::DNS MD5 HTTP::Date IO::Zlib Archive::Tar
install MIME::Base64 DB_File Net::SMTP Mail::SPF Time::HiRes</pre>
<pre>quit</pre>
</blockquote>
</blockquote>
<p>Download and unpack the sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://apache.mirror.pacific.net.au/spamassassin/source/Mail-SpamAssassin-3.2.0.tar.gz">http://apache.mirror.pacific.net.au/spamassassin/source/Mail-SpamAssassin-3.2.0.tar.gz</a></pre>
<pre>tar xzf Mail-SpamAssassin-3.2.0.tar.gz
chown -R root.root Mail-SpamAssassin-3.2.0
cd Mail-SpamAssassin-3.2.0</pre>
</blockquote>
<p>Compile and install</p>
<blockquote>
<pre>perl Makefile.PL
#[answer the questions]
make
make install</pre>
</blockquote>
<p>Setup the SpamAssassin config file. ( Note, this is a complete config file  that can replace the default supplied one )</p>
<blockquote>
<pre>vi /etc/mail/spamassassin/local.cf</pre>
<blockquote>
<pre>## Enable auto-whitelisting
use_auto_whitelist 1</pre>
<pre>####
# WILL HAVE NO EFFECT. THE EQUIVALENT SETTINGS IN AMAVISD ARE THE ONES YOU NEED TO SET
#
# ## Required point score before considered spam
# required_score 5
#
#
# ## What to tag the subject line with
# rewrite_header Subject [SPAM]
#
# ## Put the report in the headers. Dont touch the body of the message at all
# report_safe 0</pre>
<pre># Enable the Bayes system
use_bayes 1
bayes_auto_learn 1
bayes_auto_learn_threshold_spam 10</pre>
<pre>## Set headers which may provide inappropriate cues to the Bayesian
## classifier
bayes_ignore_header X-Bogosity
bayes_ignore_header X-Spam-Flag
bayes_ignore_header X-Spam-Status</pre>
<pre>## Enable or disable network checks
skip_rbl_checks 0</pre>
<pre>## File locking method. We dont need to worry about being NFS-safe
lock_method flock</pre>
<pre>## Give spamassassin some hints as to what IPs are under our control.
## Generally this will be a similar list to what you have put in the postfix mynetworks file
trusted_networks 127.0.0.1         # needed so amavisd headers don't trip up spamassassin
trusted_networks 192.168.1.0/24    # you need to include all the IPs your mail server, and local LAN workstation</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="AMAVISD"></a>AMAVISD</h3>
<p><a href="http://www.ijs.si/software/amavisd/"> http://www.ijs.si/software/amavisd/</a></p>
<p>Install some optional rpm&#8217;s that will help amavisd inspect different types of  attachments</p>
<blockquote>
<pre># These are available via yum on Fedora, but not on CentOS
yum install arc cabextract zoo lzop freeze</pre>
</blockquote>
<p>Install the prerequisite perl modules</p>
<blockquote>
<pre>perl -MCPAN -e shell</pre>
<blockquote>
<pre>o conf prerequisites_policy follow
install Archive::Zip Compress::Zlib Convert::TNEF Convert::UUlib MIME::Base64 MIME::Parser
install Mail::Internet Net::Server Digest::MD5 IO::Stringy Time::HiRes Unix::Syslog BerkeleyDB
install DBI DBD::mysql</pre>
<pre>quit</pre>
</blockquote>
</blockquote>
<p>Download and unpack the sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://www.ijs.si/software/amavisd/amavisd-new-2.5.0.tar.gz">http://www.ijs.si/software/amavisd/amavisd-new-2.5.0.tar.gz</a></pre>
<pre>tar xzf amavisd-new-2.5.0.tar.gz
chown -R root.root amavisd-new-2.5.0
cd amavisd-new-2.5.0</pre>
</blockquote>
<p>Install the program</p>
<blockquote>
<pre>mkdir /var/amavis/tmp /var/amavis/var /var/amavis/db
chown -R clamav.clamav /var/amavis
chmod -R 750 /var/amavis</pre>
<pre>cp amavisd /usr/local/sbin/
chown root /usr/local/sbin/amavisd
chmod 755 /usr/local/sbin/amavisd</pre>
<pre>cp amavisd.conf-sample /etc/amavisd.conf
chown root /etc/amavisd.conf
chmod 600 /etc/amavisd.conf</pre>
</blockquote>
<p>Make the following changes to the config file</p>
<blockquote>
<pre>vi /etc/amavisd.conf</pre>
<blockquote>
<pre>$mydomain = '<font color="#ff0000">yourdomain.com</font>';
$daemon_user = 'clamav';
$daemon_group = 'clamav';</pre>
<pre>$TEMPBASE = "$MYHOME/tmp";</pre>
<pre>$forward_method = 'smtp:[127.0.0.1]:10025';
$notify_method = $forward_method;

$max_servers = 10;

@local_domains_maps = ( [".$mydomain"] );
#
# Normally we would want a list of local domains set here,
# but when using SQL-based recipient lookups this isn't necessary.
# Doco says :
#	A special shorthand is provided when SQL lookups are used: when a match
#	for recipient address (or domain) is found in SQL tables (regardless of
#	field values), the recipient is considered local, regardless of static
#	@local_comains_acl or %local_domains lookup tables. This simplifies
#	life when a large number of dynamically changing domains is hosted.
#	To overrule this behaviour, add an explicit boolean field 'local'
#	to table 'users' (missing field defaults to true, meaning record match
#	implies the recipient is local; a NULL field 'local' is not special,
#	it is interpreted as undef like other NULL fields, causing search
#	to continue into other lookup tables).
#
# On other (non-mysql) servers that I have built as antivirus/antispam front-ends
# (which then onforward mail to server that has the mailboxes), I have used a setting like this :
#   @local_domains_maps = ("."); # consider all domains to be local</pre>
<pre>$log_level = 1;</pre>
<pre>$final_virus_destiny = D_DISCARD;
$final_banned_destiny = D_BOUNCE;
$final_spam_destiny = D_DISCARD;</pre>
<pre>$virus_admin = undef;
$spam_admin = undef;</pre>
<pre>#$QUARANTINEDIR = '/var/virusmails';</pre>
<pre>$virus_quarantine_to = undef;
$bad_header_quarantine_to = undef;
$banned_quarantine_to = undef;
$spam_quarantine_to = undef;</pre>
<pre># qr'^\.(exe-ms|dll)$',</pre>
<pre># qr'^application/x-msdownload$'i,
# qr'^application/x-msdos-program$'i,</pre>
<pre>#  qr'.\.(exe|vbs|pif|scr|cpl)$'i, # banned extension - basic
qr'.\.(vbs|pif|scr|cpl)$'i, # banned extension - basic</pre>
<pre>@spam_lovers_maps = (
  ['postmaster@', 'abuse@']
);</pre>
<pre>@lookup_sql_dsn = ( ['DBI:mysql:database=postfix;host=localhost', 'postfixuser', 'postfixpass'] );
$sql_select_policy =
  'SELECT virus_lover, spam_lover, banned_files_lover, bad_header_lover, '.
  'bypass_virus_checks, bypass_spam_checks, bypass_banned_checks, bypass_header_checks, '.
  'spam_tag2_level, spam_kill_level FROM mailbox WHERE email IN (%k)';
$sql_select_white_black_list = undef;  <span style="background-color:#ffff00;">## STILL NEED TO WORK OUT HOW TO IMPLEMENT THIS FEATURE</span></pre>
<pre>@whitelist_sender_maps = (
  ['MAILER-DAEMON@', 'postmaster@']
);</pre>
<pre>$sa_local_tests_only = 0;
$sa_tag_level_deflt = undef;
$sa_tag2_level_deflt = 5;
$sa_kill_level_deflt = 10;
$sa_dsn_cutoff_level = undef;</pre>
<pre>$sa_spam_subject_tag = '[SPAM] ';
$sa_spam_modifies_subj = 1;</pre>
<pre>### http://www.clamav.net/
['ClamAV-clamd',
\&amp;ask_daemon, ["CONTSCAN {}\n", "<strong>/var/amavis/clamd.sock</strong>"],
qr/\bOK$/, qr/\bFOUND$/,
qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],</pre>
<pre># invoke custom hooks
#my($custom_config) = '/etc/amavisd-custom.conf';
#$! = 0;
#if (!defined($custom_config)) {}
#elsif (defined(do $custom_config)) {} # good, code successfully loaded
#elsif ($@ ne '') { die "Error in config file \"$custom_config\": $@" }
#elsif ($! != 0) { die "Error reading config file \"$custom_config\": $!" }</pre>
</blockquote>
</blockquote>
<p>Install init scripts, and start the daemon</p>
<blockquote>
<pre>cp amavisd_init.sh /etc/rc.d/init.d/amavisd
chown root.root /etc/rc.d/init.d/amavisd
chmod 744 /etc/rc.d/init.d/amavisd
chkconfig --add amavisd</pre>
<pre>vi /etc/rc.d/init.d/amavisd</pre>
<blockquote>
<pre>prog="/usr<strong>/local</strong>/sbin/amavisd"</pre>
</blockquote>
<pre>/etc/rc.d/init.d/amavisd start</pre>
</blockquote>
<p>If all goes well, ps axf should show you something like this :</p>
<blockquote>
<pre>16534 ? Ss 0:00 amavisd (master)
16537 ? S 0:00   \_ amavisd (virgin child)
16538 ? S 0:00   \_ amavisd (virgin child)
16539 ? S 0:00   \_ amavisd (virgin child)
16540 ? S 0:00   \_ amavisd (virgin child)
16541 ? S 0:00   \_ amavisd (virgin child)
16542 ? S 0:00   \_ amavisd (virgin child)
16543 ? S 0:00   \_ amavisd (virgin child)
16544 ? S 0:00   \_ amavisd (virgin child)
16545 ? S 0:00   \_ amavisd (virgin child)
16546 ? S 0:00   \_ amavisd (virgin child)</pre>
</blockquote>
<p>Add these commands to tell Postfix to use Amavis for scanning</p>
<blockquote>
<p align="left">
<pre>vi /etc/postfix/main.cf</pre>
<p align="left">
<blockquote>
<pre>content_filter=smtp-amavis:[127.0.0.1]:10024
smtp-amavis_destination_concurrency_limit=10</pre>
</blockquote>
<p align="left">
<pre>vi /etc/postfix/master.cf</pre>
<p align="left">
<blockquote>
<pre>smtp-amavis unix - - n - - lmtp
  -o lmtp_data_done_timeout=1200
  -o lmtp_send_xforward_command=yes
  -o lmtp_connection_timeout=2
  -o disable_dns_lookups=yes
  -o max_use=20</pre>
</blockquote>
<blockquote>
<pre>127.0.0.1:10025 inet n - n - - smtpd-av
  -o content_filter=
  -o smtpd_restriction_classes=
  -o smtpd_delay_reject=no
  -o smtpd_client_restrictions=permit_mynetworks,reject
  -o smtpd_helo_restrictions=
  -o smtpd_sender_restrictions=
  -o smtpd_recipient_restrictions=permit_mynetworks,reject
  -o smtpd_data_restrictions=reject_unauth_pipelining
  -o smtpd_end_of_data_restrictions=
  -o mynetworks=127.0.0.0/8
  -o smtpd_error_sleep_time=0
  -o smtpd_soft_error_limit=1001
  -o smtpd_hard_error_limit=1000
  -o smtpd_client_connection_count_limit=0
  -o smtpd_client_connection_rate_limit=0
  -o smtpd_milters=
  -o local_header_rewrite_clients=
  -o local_recipient_maps=
  -o relay_recipient_maps=
  -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks,no_address_mappings</pre>
</blockquote>
<pre>cd /usr/libexec/postfix
ln -s smtpd smtpd-av</pre>
<pre>postfix reload</pre>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Disable  logwatch script from reporting on amavisd logs</p>
<blockquote><p>The logwatch script runs nightly, and emails a report to the root user  	Unless your server is very low volume, I would recommend you tell logwatch  	not to report amavisd stats, otherwise the report gets much too big</p>
<pre>vi /etc/log.d/conf/logwatch.conf</pre>
<blockquote>
<pre># Look for where it says "Service = All" and underneath that add this line :
Service = -amavis</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="PUREFTPD"></a>PUREFTPD</h3>
<p><a href="http://www.pureftpd.org/">http://www.pureftpd.org</a></p>
<p>Pureftpd has been chosen because it supports MySQL and softquotas. The  softquotas work in a similar way to the maildir++ quota system. But instead of  the quotas being stored in a maildirsize file, they are stored in a file called  &#8220;.ftpquota&#8221;</p>
<p>Download and unpack</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz">http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz</a>
tar xzf pure-ftpd-1.0.21.tar.gz
chown -R root.root pure-ftpd-1.0.21
cd pure-ftpd-1.0.21</pre>
</blockquote>
<p>configure, compile, install</p>
<blockquote>
<pre>./configure \
  --without-inetd \
  --without-shadow \
  --without-humor \
  --without-usernames \
  --with-boring \
  --with-extauth \
  --with-mysql \
  --with-quotas \
  --with-virtualchroot \
  --with-cookie \
  --with-tls \
  --with-certfile=/usr/local/ssl/mail.<font color="#ff0000">yourdomain.com</font>.pem</pre>
<p><span style="background-color:#ffff00;"># Note, the configure script will    emit this warning :<br />
# &#8220;configure: WARNING: No certificate is installed in /usr/local/ssl/mail.<font color="#ff0000">yourdomain.com</font>.pem yet&#8221;.<br />
# However apon inspecting the source code it can be seen this is a bug. If the    file exists it reports that warning,<br />
# when it should actually report that warning if the file is missing. I have    reported that bug to the pureftpd authors.<br />
# They have acknowledged the bug and the fix will be included in v1.0.22</span></p>
<table style="border-collapse:collapse;" border="1" cellpadding="3" cellspacing="3">
<tr>
<td>TIP : If you are using x86_64 platform ( eg Opteron ), you will have        to modify your configure command to be :</p>
<pre><strong>LDFLAGS=-L/usr/lib64/mysql \
</strong>./configure \
  --without-inetd \
  ......etc</pre>
</td>
</tr>
</table>
<pre></pre>
<pre>make
make install-strip</pre>
</blockquote>
<p>Setup the config file by making these changes</p>
<blockquote>
<pre>cp pureftpd-mysql.conf /etc</pre>
<pre>vi /etc/pureftpd-mysql.conf</pre>
<blockquote>
<pre>#MYSQLServer 127.0.0.1
#MYSQLPort 3306
MYSQLSocket /var/lib/mysql/mysql.sock
MYSQLUser postfixuser
MYSQLPassword postfixpass
MYSQLDatabase postfix
MYSQLCrypt cleartext
MYSQLGetPW SELECT clear_password FROM mailbox WHERE email="\L" AND disableftp=0
#MYSQLGetUID SELECT Uid FROM mailbox WHERE email="\L"
MYSQLDefaultUID 1001
#MYSQLGetGID SELECT Gid FROM mailbox WHERE email="\L"
MYSQLDefaultGID 1001
MYSQLGetDir SELECT CONCAT('/var/vmail/',maildir,'public_html') FROM mailbox WHERE email="\L" AND disableftp=0
MySQLGetQTASZ SELECT ftpquota*1024 FROM mailbox WHERE email="\L" and disableftp=0</pre>
</blockquote>
<pre>chmod 600 /etc/pureftpd-mysql.conf</pre>
</blockquote>
<p>Setup a welcome banner</p>
<blockquote>
<pre>echo "##-------------------------------------------"    &gt;  /etc/pureftpd-banner.txt
echo "## <font color="#ff0000">yourdomain.com</font> users FTP"                      &gt;&gt; /etc/pureftpd-banner.txt
echo "##-------------------------------------------"    &gt;&gt; /etc/pureftpd-banner.txt
echo "##"                                               &gt;&gt; /etc/pureftpd-banner.txt
echo "## IMPORTANT"                                     &gt;&gt; /etc/pureftpd-banner.txt
echo "## Please login using your full email address"    &gt;&gt; /etc/pureftpd-banner.txt
echo "## eg username@<font color="#ff0000">yourdomain.com</font>"                    &gt;&gt; /etc/pureftpd-banner.txt
echo "##"                                               &gt;&gt; /etc/pureftpd-banner.txt
echo "##-------------------------------------------"    &gt;&gt; /etc/pureftpd-banner.txt</pre>
<pre>chmod 644 /etc/pureftpd-banner.txt</pre>
</blockquote>
<p>Configure pureftpd to start at boot time</p>
<blockquote>
<pre>vi /etc/rc.d/rc.local</pre>
<blockquote>
<pre>/usr/local/sbin/pure-ftpd -l mysql:/etc/pureftpd-mysql.conf --noanonymous --ipv4only --fortunesfile=/etc/pureftpd-banner.txt --createhomedir --customerproof --tls=1 --daemonize</pre>
</blockquote>
</blockquote>
<p>Start pureftpd</p>
<blockquote>
<pre>/usr/local/sbin/pure-ftpd -l mysql:/etc/pureftpd-mysql.conf --noanonymous --ipv4only --fortunesfile=/etc/pureftpd-banner.txt --createhomedir --customerproof --tls=1 --daemonize</pre>
<p>If all goes well, ps axf should show something like this :</p>
<blockquote>
<pre>11204 ? Ss 0:00 pure-ftpd (SERVER)</pre>
</blockquote>
</blockquote>
<p>Allow your IPTables to handle ftp connections at least semi-gracefully</p>
<blockquote>
<pre>vi /etc/rc.d/rc.local</pre>
<blockquote>
<pre>/sbin/modprobe ip_conntrack_ftp</pre>
</blockquote>
</blockquote>
<p>Setup a crontab    to ensure virtual quotas are always kept correct. Especially important after    you have copied any content into the public_html dirs using a method other    than pureftpd</p>
<blockquote>
<pre>vi /usr/local/sbin/rebuild-ftp-softquotas.pl</pre>
<blockquote>
<pre>#!/usr/bin/perl -w
##
## Loop through SQL and extract a list of userdirs
## For each user, recalc their ftp softquota file
##
use strict;
use DBI;
my $dbh = DBI-&gt;connect('DBI:mysql:postfix', 'postfixuser', 'postfixpass') || die "Database connection failed: $DBI::errstr";
my $sql = "SELECT CONCAT('/var/vmail/',maildir) AS homedir FROM mailbox WHERE active=1 ORDER BY maildir";
my $sth = $dbh-&gt;prepare($sql);
$sth-&gt;execute() || die "Could not execute SQL statement";
while (my($homedir)=$sth-&gt;fetchrow_array) {
    my $ftpdir = $homedir . "public_html";
    if (-d "$ftpdir") {
        my $escaped_ftpdir = $ftpdir;
        $escaped_ftpdir =~ s/\&amp;/\\&amp;/g;
        $escaped_ftpdir =~ s/\ /\\ /g;
        my $cmd = sprintf ("/usr/local/sbin/pure-quotacheck -u 1001 -g 1001 -d $escaped_ftpdir");
        system ($cmd);
    } else {
        print ("WARNING: dir does not exist : $ftpdir\n");
    }
}
$sth-&gt;finish();
$dbh-&gt;disconnect();</pre>
</blockquote>
<pre>chmod 700 /usr/local/sbin/rebuild-ftp-softquotas.pl</pre>
<pre>crontab -e</pre>
<blockquote>
<pre>### Periodically recalc all the ftp softquotas ( just in case )
0 2 * * Sun /bin/nice /usr/local/sbin/rebuild-ftp-softquotas.pl</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="LAST_ BITS_OF_CLEANUP"></a>LAST BITS OF CLEANUP</h3>
<p>Remove some unneeded stuff from MySQL, and set some passwords</p>
<blockquote>
<pre>mysql</pre>
<blockquote>
<pre>-- MySQL comes with a "test" database and an anonymous user which has access to the test database
-- We don't want either of these so lets get rid of them now
<strong>DROP DATABASE test;
</strong><strong><code>DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.db WHERE User='';</code></strong></pre>
<pre>-- Set a root password ( by default there is no password set,
-- which means anyone with shell access could type "mysql -u root" and login to MySQL as root user )
<strong><code>UPDATE mysql.user SET Password = PASSWORD('<em>newpwd</em>') WHERE User = 'root';</code></strong></pre>
<pre><code><strong>-- Tell MySQL to pickup our username/password changes</strong><strong>
FLUSH PRIVILEGES;</strong></code></pre>
</blockquote>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Setup a  config file that stores the MySQL root password, so the system root user doesn&#8217;t  have to type the MySQL root password when logging into MySQL</p>
<blockquote>
<pre>vi /root/.my.cnf</pre>
<blockquote>
<pre>[client]
password=newpwd</pre>
</blockquote>
<pre>chmod 600 /root/.my.cnf</pre>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Create a  local user for yourself, and disable root SSH logins</p>
<blockquote><p>By default the SSH daemon will permit root logins. Its a security risk to  	leave this enabled. I would recommend you create a local account which you  	can use when connecting via SSH. Once connected you can then type &#8220;su -&#8221; to  	switch to the root user if required.</p>
<blockquote>
<pre>useradd someuser
passwd someuser</pre>
<pre>vi /etc/ssh/sshd_config</pre>
<blockquote>
<pre>PermitRootLogin no</pre>
</blockquote>
<pre>/etc/rc.d/init.d/sshd restart</pre>
</blockquote>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Here&#8217;s a  script which I use to periodically create any missing softquota files. I run  this weekly from crontab. Note the script tests for chmod 0 on the user&#8217;s  public_html : this is done because when I suspend a user for non-payment etc I  go and set their disableftp/imap/pop3/webmail=1 in the mailbox table ( but leave  active=1 so incoming mail doesn&#8217;t get bounced), and I also chmod 0 their  public_html dir to stop their webpages from being served.</p>
<blockquote>
<pre>vi /usr/local/sbin/create-missing-softquotas.pl</pre>
<blockquote>
<pre>#!/usr/bin/perl -w</pre>
<pre>### Wonder if it would be worth while enhancing the script further to autocreate missing dirs?
### Might be bad news though if the db contains some sort of shonky home dir info
### Maybe just sending an email alert to admin is the best bet, get someone to investigate manually.
###</pre>
<pre>use strict;
use DBI;
my $dbh = DBI-&gt;connect('DBI:mysql:postfix', 'postfixuser', 'postfixpass');
my $sql = "SELECT CONCAT('/var/vmail/',maildir) as homedir, CONCAT(mailquota*1024*1024,'S') AS mailquota, ftpquota*1024 as ftpquota FROM mailbox WHERE active=1 ORDER BY maildir";
my $sth = $dbh-&gt;prepare($sql);
$sth-&gt;execute() || die "Could not execute SQL statement";
my $cmd;
while (my($homedir, $mailquota, $ftpquota)=$sth-&gt;fetchrow_array) {</pre>
<blockquote>
<pre># chop the trailing slash off the homedir
$homedir =~ s/\/$//;
#print "checking $homedir ($mailquota, $ftpquota) ..\n";
unless (-e "$homedir/Maildir/maildirsize") {</pre>
<blockquote>
<pre>if (-d "$homedir/Maildir") {</pre>
<blockquote>
<pre>print "maildirsize missing from $homedir/Maildir, creating it now\n";
my $escaped_maildir = $homedir . "/Maildir";
$escaped_maildir =~ s/\&amp;/\\&amp;/g;
$escaped_maildir =~ s/\ /\\ /g;
#### Create the quota file
$cmd = sprintf ("/usr/local/courier-imap/bin/maildirmake -q $mailquota $escaped_maildir");
system ($cmd);
#### Fix up permissions
$cmd = sprintf ("chown vmail.vmail $escaped_maildir/maildirsize");
system ($cmd);
$cmd = sprintf ("chmod 600 $escaped_maildir/maildirsize");
system ($cmd);</pre>
</blockquote>
<pre>} else {</pre>
<blockquote>
<pre>print "Error, $homedir/Maildir doesnt exist, this needs to be rectified\n";</pre>
</blockquote>
<pre>}</pre>
</blockquote>
<pre>}</pre>
<pre>unless (-e "$homedir/public_html/.ftpquota") {</pre>
<blockquote>
<pre>if (-d "$homedir/public_html") {</pre>
<blockquote>
<pre># bypass any dirs that have been chmod to 0 ( suspended )
my $mode = (stat $homedir."/public_html")[2];
unless ($mode == 0x4000) {</pre>
<blockquote>
<pre>print ".ftpquota missing from $homedir/public_html, creating it now\n";
my $escaped_ftpdir = $homedir . "/public_html";
$escaped_ftpdir =~ s/\&amp;/\\&amp;/g;
$escaped_ftpdir =~ s/\ /\\ /g;
$cmd = sprintf ("/usr/local/sbin/pure-quotacheck -u 1001 -g 1001 -d $escaped_ftpdir");
system ($cmd);</pre>
</blockquote>
<pre>}</pre>
</blockquote>
<pre>} else {</pre>
<blockquote>
<pre>print "Error, $homedir/public_html doesnt even exist, this needs to be rectified\n";</pre>
</blockquote>
<pre>}</pre>
</blockquote>
<pre>}</pre>
</blockquote>
<pre>}</pre>
<pre>$sth-&gt;finish();
$dbh-&gt;disconnect();</pre>
</blockquote>
<pre>chmod 700 /usr/local/sbin/create-missing-softquotas.pl</pre>
<pre>crontab -e</pre>
<blockquote>
<pre>0 3 * * * /bin/nice /usr/local/sbin/create-missing-softquotas.pl</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="SAMPLE_TEST_DATA"></a>SAMPLE / TEST DATA</h3>
<p>Notes :</p>
<blockquote><p><strong>For every new virtual mailbox domain, insert a new row into the &#8216;mailbox_domains&#8217; table</strong></p>
<p><strong>For every new virtual mailbox user, insert a new row into the &#8216;mailbox&#8217; table,    and create their maildir on the disk.   </strong>Note: In our example we are going to &#8220;hash&#8221; the path to the user&#8217;s dir, by taking the first letter of the username and putting that into the path eg domain/&lt;1stletter&gt;/username. This is done to the system from slowing down when it has to working with a directory that contains a huge number of entries. If you only plan to have a few hundred users you could probably go without any hashing. If you have thousands of users then 1 level of hashing is a good idea. If you have many tens of thousands of users then you might want to increase the level of hashing eg domain/&lt;1stletter&gt;/&lt;1stletter&gt;&lt;2ndletter&gt;/username, or domain/&lt;firstletter&gt;&lt;2ndletter&gt;/username)</p>
<p><strong>For every new virtual alias domain, insert a new row into the &#8216;alias_domains&#8217;    table</strong></p>
<p><strong>For every every new alias/forward (doesn&#8217;t matter if they are for a    mailbox_domain or alias_domain), insert a row into the &#8216;alias&#8217; table </strong></p></blockquote>
<p>Here is some examples of data  :</p>
<blockquote>
<pre>use postfix;</pre>
<pre>----------------------------------------------------------------------------------------------------
-- Tell postfix which domains we host this as virtual mailbox domains
--
INSERT INTO mailbox_domains ( domain, description, created, modified )
VALUES ('testdomain.com', 'Postfix virtual mailbox domain', NOW(), NOW());</pre>
<pre>INSERT INTO mailbox_domains ( domain, description, created, modified )
VALUES ('testdomain2.com', 'Postfix virtual mailbox domain', NOW(), NOW());</pre>
<pre>----------------------------------------------------------------------------------------------------
-- Tell postfix about the virtual mailboxes that we host
--
-- Note that when generating the crypted password, you can't use the MySQL CRYPT function.
-- If you are migrating users out of an /etc/passwd type file, you can just copy the crypted password
-- from there.
-- If you need to generate a crypted password, you can use some code this like :
--   perl -e "print crypt('testpass', join '', ('.', '/', 0..9,'A'..'Z', 'a'..'z')[rand 64, rand 64]);"
--
-- If you don't enter the clear password, password auth will still work, except for auth methods
-- that require the clear password to be available eg CRAM or DIGEST. <a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#NO_CLEAR_PASSWORDS">More info on this subject here</a>
--
-- We haven't defined any of the spam_lover columns etc. If you don't specify a value there, amavisd
-- will just apply its default settings from amavisd.conf ( virusscanning on, antispam scanning on, tag at 5 drop at 10 etc )
--
INSERT INTO mailbox (email, password, clear_password, maildir, created, modified)
VALUES ('user1@testdomain.com', 'dzOCCGgyq3TVo', 'testpass', 'testdomain.com/u/user1/', NOW(), NOW());</pre>
<pre>INSERT INTO mailbox (email, password, clear_password, maildir, created, modified)
VALUES ('someuser2@testdomain.com', 'dzOCCGgyq3TVo', 'testpass', 'testdomain.com/s/someuser2/', NOW(), NOW());</pre>
<pre>INSERT INTO mailbox (email, password, clear_password, maildir, created, modified)
VALUES ('user1@testdomain2.com', 'dzOCCGgyq3TVo', 'testpass', 'testdomain2.com/u/user1/', NOW(), NOW());</pre>
<pre>INSERT INTO mailbox (email, password, clear_password, maildir, created, modified)
VALUES ('thisuser2@testdomain2.com', 'dzOCCGgyq3TVo', 'testpass', 'testdomain2.com/t/thisuser2/', qNOW(), NOW());</pre>
<pre>----------------------------------------------------------------------------------------------------
-- Add in some alias address mappings
--
INSERT INTO alias (address, goto, created, modified)
VALUES ('user3@testdomain.com', 'user2@hotmail.com', NOW(), NOW());</pre>
<pre>INSERT INTO alias (address, goto, created, modified)
VALUES ('sales@testdomain.com', 'someuser2@testdomain.com', NOW(), NOW());</pre>
<pre>-- "Catchall" entry
INSERT INTO alias (address, goto, created, modified)
VALUES ('@testdomain.com', 'user1@testdomain.com', NOW(), NOW());</pre>
</blockquote>
<p>To create the Maildirs on the disk you will need some commands like :</p>
<blockquote>
<pre># create the full directory tree through to the users dir
mkdir -p /var/vmail/testdomain.com/u/user1/public_html
# create the maildir structure
maildirmake /var/vmail/testdomain.com/u/user1/Maildir
# create the softquota "maildirsize" file in the maildir.
# ( If this file isn't present, no quotas will be enforced )
maildirmake -q 20971520S /var/vmail/testdomain.com/u/user1/Maildir
chmod g-r,o-r /var/vmail/testdomain.com/u/user1/Maildir/maildirsize
chown -R vmail.vmail /var/vmail/testdomain.com/u/user1</pre>
</blockquote>
<p>You can also host non-mailbox domains, where all addresses are forwarding on  to other locations :<br />
Note that postfix will use any user@domain mappings before any @domain mappings  are matched</p>
<blockquote>
<pre>----------------------------------------------------------------------------------------------------
INSERT INTO alias_domains ( domain, description, created, modified )
VALUES ('testdomain3.com', 'Postfix virtual alias domain', NOW(), NOW());</pre>
<pre>-- map xxx@testdomain3.com to xxx@testdomain.com
INSERT INTO alias (address, goto, created, modified)
VALUES ('@testdomain3.com', '@testdomain.com', NOW(), NOW());</pre>
<pre>----------------------------------------------------------------------------------------------------
INSERT INTO alias_domains ( domain, description, created, modified )
VALUES ('testdomain4.com', 'Postfix virtual alias domain', NOW(), NOW());</pre>
<pre>INSERT INTO alias (address, goto, created, modified)
VALUES ('user1@testdomain4.com', 'jim@blah.com', NOW(), NOW());</pre>
<pre>INSERT INTO alias (address, goto, created, modified)
VALUES ('user2@testdomain4.com', 'john@something.com', NOW(), NOW());</pre>
<pre>INSERT INTO alias (address, goto, created, modified)
VALUES ('@testdomain4.com', 'fred@somewhere.com', NOW(), NOW());</pre>
</blockquote>
<p>Here are some examples of data for the &#8220;access&#8221; files :</p>
<blockquote>
<pre>-- Always permit mail to our abuse and postmaster addresses.
-- Don't do RBL checking etc for such mail
INSERT INTO recipient_access ( recipient, response, note, created, modified )
VALUES ('abuse', 'OK', 'Dont do RBL checking etc for mail to our abuse address', NOW(), NOW());
INSERT INTO recipient_access ( recipient, response, note, created, modified )
VALUES ('postmaster', 'OK', 'Dont do RBL checking etc for mail to our postmaster address', NOW(), NOW());</pre>
<pre>-- match incoming smtp connections based on senders IP
INSERT INTO client_access ( client, response, created, modified )
VALUES ('66.6.223.100','REJECT Sorry, you are sending spam', NOW(), NOW());</pre>
<pre>-- match incoming smtp connections based on senders address
INSERT INTO sender_access ( sender, response, created, modified )
VALUES ('support@westpac.com.au', 'REJECT Sober VIRUS', NOW(), NOW());</pre>
<pre>-- recipient access can be handy if you have a customer who has configured
-- a wildcard mapping enabled for their domain, but wants to reject one
-- particular address from matching the wildcard
INSERT INTO recipient_access ( recipient, response, note, created, modified )
VALUES ('example@testdomain2.com', 'REJECT Mailbox closed', NOW(), NOW());</pre>
</blockquote>
<hr />
<h3><a name="MRTG_/_SNMP"></a>MRTG / SNMP</h3>
<p><a href="http://people.ee.ethz.ch/%7Eoetiker/webtools/mrtg/"> http://people.ee.ethz.ch/~oetiker/webtools/mrtg/</a></p>
<p>You want to be able to keep an eye on your mail server using MRTG</p>
<p>Install the SNMP applications</p>
<blockquote>
<pre>yum install net-snmp net-snmp-utils</pre>
</blockquote>
<p>Add some basic scripts for snmpd to make use of</p>
<blockquote>
<pre>echo '#!/bin/sh' &gt; /usr/local/bin/mrtg-incoming-count.sh
echo 'find /var/spool/postfix/incoming -type f | wc -l' &gt;&gt; /usr/local/bin/mrtg-incoming-count.sh
chmod 744 /usr/local/bin/mrtg-incoming-count.sh</pre>
<pre>echo '#!/bin/sh' &gt; /usr/local/bin/mrtg-active-count.sh
echo 'find /var/spool/postfix/active -type f | wc -l' &gt;&gt; /usr/local/bin/mrtg-active-count.sh
chmod 744 /usr/local/bin/mrtg-active-count.sh</pre>
<pre>echo '#!/bin/sh' &gt; /usr/local/bin/mrtg-deferred-count.sh
echo 'find /var/spool/postfix/deferred -type f | wc -l' &gt;&gt; /usr/local/bin/mrtg-deferred-count.sh
chmod 744 /usr/local/bin/mrtg-deferred-count.sh</pre>
</blockquote>
<p>Configure the snmpd</p>
<blockquote>
<pre>echo 'com2sec local localhost <font color="#ff0000">yourstring</font>' &gt; /etc/snmp/snmpd.conf
echo 'com2sec mynetwork <font color="#ff0000">xxx.xxx.xxx.xxx/32 yourstring</font>' &gt;&gt;/etc/snmp/snmpd.conf
echo 'group MyROGroup v1 local' &gt;&gt;/etc/snmp/snmpd.conf
echo 'group MyROGroup v1 mynetwork' &gt;&gt;/etc/snmp/snmpd.conf
echo 'view all included .1 80' &gt;&gt;/etc/snmp/snmpd.conf
echo 'access MyROGroup "" any noauth exact all none none' &gt;&gt;/etc/snmp/snmpd.conf
echo 'syslocation Some Location' &gt;&gt;/etc/snmp/snmpd.conf
echo 'syscontact Some Name &lt;some@emailaddress&gt;' &gt;&gt;/etc/snmp/snmpd.conf</pre>
<pre>echo 'proc pipe' &gt;&gt;/etc/snmp/snmpd.conf
echo 'proc smtp' &gt;&gt;/etc/snmp/snmpd.conf
echo 'proc lmtp' &gt;&gt;/etc/snmp/snmpd.conf
echo 'proc smtpd-mx' &gt;&gt;/etc/snmp/snmpd.conf
echo 'proc pop3d' &gt;&gt;/etc/snmp/snmpd.conf
echo 'proc imapd' &gt;&gt;/etc/snmp/snmpd.conf</pre>
<pre>echo 'exec active-count /bin/sh /usr/local/bin/mrtg-active-count.sh' &gt;&gt;/etc/snmp/snmpd.conf
echo 'exec incoming-count /bin/sh /usr/local/bin/mrtg-incoming-count.sh' &gt;&gt;/etc/snmp/snmpd.conf
echo 'exec deferred-count /bin/sh /usr/local/bin/mrtg-deferred-count.sh' &gt;&gt;/etc/snmp/snmpd.conf</pre>
</blockquote>
<p>Protect your SNMP password from prying eyes</p>
<blockquote><p>chmod 600 /etc/snmp/snmpd.conf</p></blockquote>
<p>Configure snmpd to launch at boot time</p>
<blockquote>
<pre>chkconfig snmpd on</pre>
</blockquote>
<p>Start snmpd</p>
<blockquote>
<pre>/etc/rc.d/init.d/snmpd start</pre>
<p>ps axf should give something like this :</p>
<blockquote>
<pre>9918 ? S 0:00 /usr/sbin/snmpd -Lsd -Lf /dev/null -p /var/run/snmpd -a</pre>
</blockquote>
</blockquote>
<p>Here is an example mrtg cfg file for polling your server</p>
<blockquote>
<pre>Workdir: /home/httpd/stats/html/mail-servers/data
IconDir: /images
	Options[^]: growright, unknaszero
WithPeak[^]: ymw
XSize[^]: 180

##Remarked out this next line out, as it means you are only alerted when threshold is crossed
##Rather than nagged repeatedly that you are over threshold
##For us, being nagged is better I reckon <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />
##ThreshDir: /home/httpd/stats/thresh
ThreshProgI[_]: /home/httpd/stats/mrtg-threshwarn.pl
ThreshProgOKI[_]: /home/httpd/stats/mrtg-threshwarn.pl
ThreshProgO[_]: /home/httpd/stats/mrtg-threshwarn.pl
ThreshProgOKO[_]: /home/httpd/stats/mrtg-threshwarn.pl</pre>
<pre>#----------------------------------------------------------------------
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.eth]: 2:yourstring@mail.<font color="#ff0000">yourdomain.com</font>:
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.eth]: 1250000
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.eth]: 12500000
Title[mail.<font color="#ff0000">yourdomain.com</font>.eth]: Traffic Analysis for eth0 -- mail.<font color="#ff0000">yourdomain.com</font>
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.eth]: &lt;H1&gt;Traffic Analysis for eth0 -- mail.<font color="#ff0000">yourdomain.com</font>&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.eth]: bits, unknaszero
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: .1.3.6.1.4.1.2021.10.1.3.2&amp;.1.3.6.1.4.1.2021.10.1.3.3:yourstring@mail.<font color="#ff0000">yourdomain.com</font> * 100
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: 1000
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: 50000
Title[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: System Load Average for mail.<font color="#ff0000">yourdomain.com</font>
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: &lt;H1&gt; System Load Average for mail.<font color="#ff0000">yourdomain.com</font> (*100) &lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: gauge, unknaszero
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: Load Average
ShortLegend[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: load
Legend1[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: Load Average over 5 Minutes
LegendI[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: 5 min:
LegendO[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: 15 min:
ThreshMaxI[mail.<font color="#ff0000">yourdomain.com</font>.cpu]: 8000
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: .1.3.6.1.2.1.25.2.3.1.6.2&amp;.1.3.6.1.2.1.25.2.3.1.6.2:yourstring@mail.<font color="#ff0000">yourdomain.com</font>
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: 2075988
Title[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: Real Memory
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: &lt;h1&gt;Real memory on mail.<font color="#ff0000">yourdomain.com</font>&lt;/h1&gt;
Unscaled[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: dwmy
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: Real Memory
Options[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: Gauge, Integer, unknaszero
#Kilo[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: 1024
kMG[mail.<font color="#ff0000">yourdomain.com</font>.realmem]: Kb,Mb,Gb,Tb,Pb
ShortLegend[mail.<font color="#ff0000">yourdomain.com</font>.realmem]:
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: .1.3.6.1.2.1.25.2.3.1.6.3&amp;.1.3.6.1.2.1.25.2.3.1.6.3:yourstring@mail.<font color="#ff0000">yourdomain.com</font>
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: 4096532
Title[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: Swap Memory
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: &lt;h1&gt;Swap memory on mail.<font color="#ff0000">yourdomain.com</font>&lt;/h1&gt;
Unscaled[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: dwmy
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: Swap Memory
Options[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: Gauge, Integer, unknaszero
#Kilo[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: 1024
kMG[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: Kb,Mb,Gb,Tb,Pb
ShortLegend[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]:
ThreshMaxI[mail.<font color="#ff0000">yourdomain.com</font>.swapmem]: 20%
#----------------------------------------------------------------------
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.postfix.virtual]: .1.3.6.1.4.1.2021.2.1.5.1&amp;.1.3.6.1.4.1.2021.2.1.5.1:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.postfix.virtual]: 100
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.postfix.virtual]: 1000
Title[mail.<font color="#ff0000">yourdomain.com</font>.postfix.virtual]: mail.<font color="#ff0000">yourdomain.com</font> : Postfix virtual-mailbox delivery processes
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.postfix.virtual]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : Postfix virtual-mailbox delivery processes&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.postfix.virtual]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.postfix.virtual]: processes
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtp]: .1.3.6.1.4.1.2021.2.1.5.2&amp;.1.3.6.1.4.1.2021.2.1.5.2:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtp]: 100
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtp]: 1000
Title[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtp]: mail.<font color="#ff0000">yourdomain.com</font> : Postfix outbound smtp processes
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtp]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : Postfix outbound smtp processes&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtp]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtp]: processes
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.postfix.lmtp]: .1.3.6.1.4.1.2021.2.1.5.3&amp;.1.3.6.1.4.1.2021.2.1.5.3:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.postfix.lmtp]: 100
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.postfix.lmtp]: 1000
Title[mail.<font color="#ff0000">yourdomain.com</font>.postfix.lmtp]: mail.<font color="#ff0000">yourdomain.com</font> : Postfix smtp-amavis processes
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.postfix.lmtp]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : Postfix smtp-amavis processes&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.postfix.lmtp]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.postfix.lmtp]: processes
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtpd-mx]: .1.3.6.1.4.1.2021.2.1.5.4&amp;.1.3.6.1.4.1.2021.2.1.5.4:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtpd-mx]: 100
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtpd-mx]: 1000
Title[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtpd-mx]: mail.<font color="#ff0000">yourdomain.com</font> : Postfix smtpd-mx processes
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtpd-mx]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : Postfix smtpd-mx processes&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtpd-mx]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.postfix.smtpd-mx]: processes
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.pop3d]: .1.3.6.1.4.1.2021.2.1.5.5&amp;.1.3.6.1.4.1.2021.2.1.5.5:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.pop3d]: 100
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.pop3d]: 1000
Title[mail.<font color="#ff0000">yourdomain.com</font>.pop3d]: mail.<font color="#ff0000">yourdomain.com</font> : pop3d processes
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.pop3d]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : pop3d processes&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.pop3d]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.pop3d]: processes
ThreshMaxI[mail.<font color="#ff0000">yourdomain.com</font>.pop3d]: 150
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.imapd]: .1.3.6.1.4.1.2021.2.1.5.6&amp;.1.3.6.1.4.1.2021.2.1.5.6:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.imapd]: 100
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.imapd]: 1000
Title[mail.<font color="#ff0000">yourdomain.com</font>.imapd]: mail.<font color="#ff0000">yourdomain.com</font> : imapd processes
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.imapd]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : imapd processes&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.imapd]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.imapd]: processes
ThreshMaxI[mail.<font color="#ff0000">yourdomain.com</font>.imapd]: 150
#----------------------------------------------------------------------
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.postfix.active-count]: .1.3.6.1.4.1.2021.8.1.101.1&amp;.1.3.6.1.4.1.2021.8.1.101.1:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.postfix.active-count]: 1000
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.postfix.active-count]: 1000000
Title[mail.<font color="#ff0000">yourdomain.com</font>.postfix.active-count]: mail.<font color="#ff0000">yourdomain.com</font> : Postfix active queue
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.postfix.active-count]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : Postfix active queue&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.postfix.active-count]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.postfix.active-count]: Messages
ThreshMaxI[mail.<font color="#ff0000">yourdomain.com</font>.postfix.active-count]: 2000
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.postfix.incoming-count]: .1.3.6.1.4.1.2021.8.1.101.2&amp;.1.3.6.1.4.1.2021.8.1.101.2:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.postfix.incoming-count]: 1000
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.postfix.incoming-count]: 1000000
Title[mail.<font color="#ff0000">yourdomain.com</font>.postfix.incoming-count]: mail.<font color="#ff0000">yourdomain.com</font> : Postfix incoming queue
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.postfix.incoming-count]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : Postfix incoming queue&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.postfix.incoming-count]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.postfix.incoming-count]: Messages
ThreshMaxI[mail.<font color="#ff0000">yourdomain.com</font>.postfix.incoming-count]: 2000
#----------------------------------------------------------------------
Target[mail.<font color="#ff0000">yourdomain.com</font>.postfix.deferred-count]: .1.3.6.1.4.1.2021.8.1.101.3&amp;.1.3.6.1.4.1.2021.8.1.101.3:yourstring@mail.<font color="#ff0000">yourdomain.com</font>::10
MaxBytes[mail.<font color="#ff0000">yourdomain.com</font>.postfix.deferred-count]: 1000
AbsMax[mail.<font color="#ff0000">yourdomain.com</font>.postfix.deferred-count]: 1000000
Title[mail.<font color="#ff0000">yourdomain.com</font>.postfix.deferred-count]: mail.<font color="#ff0000">yourdomain.com</font> : Postfix deferred queue
PageTop[mail.<font color="#ff0000">yourdomain.com</font>.postfix.deferred-count]: &lt;H1&gt;mail.<font color="#ff0000">yourdomain.com</font> : Postfix deferred queue&lt;/H1&gt;
Options[mail.<font color="#ff0000">yourdomain.com</font>.postfix.deferred-count]: gauge, integer
YLegend[mail.<font color="#ff0000">yourdomain.com</font>.postfix.deferred-count]: Messages</pre>
</blockquote>
<pre>The mrtg-threshwarn.pl script looks like this :</pre>
<blockquote>
<pre>#!/usr/bin/perl -w
#
# Called when MRTG detects a threshold problem for a variable.
# ARGV[0] = Parameter name, such as 'wanrouter.cpu'.
# ARGV[1] = Threshold value which was breached, such as "99".
# ARGV[2] = Actual current value of the parameter, such as "100".
#
# Command line looks like:
# thisprogram wanrouter 99[%] 100 description 100
#
my($timestr, $param, $thresh, $raw, $description, $value, $message, $logfile);
$timestr = localtime(time);
$param = $ARGV[0];
$thresh = $ARGV[1];
$raw = $ARGV[2];
$description = $ARGV[3];
$value = $ARGV[4];</pre>
<pre>$emailprog = "/usr/sbin/sendmail";
$emailuser = "admin\@yourdomain.com";</pre>
<pre>$percent = "";
$bracket = "";
if ($thresh =~ /%$/) {
$thresh = substr($thresh, 0, length($thresh)-1);
$percent = "%";
$raw = "$raw (";
$bracket = ")";
}else{
$raw = "";</pre>
<pre>if ($thresh &gt; $value) {
$abovebelow = "below";
} else {
$abovebelow = "above";
}</pre>
<pre>$message = "Notice ! $param is $abovebelow threshold $thresh$percent. Current value is $raw$value$percent$bracket";

#$message .= "Notice ! $param ($value) has passed threshold ($thresh)";

system("echo 'Subject: $message' | $emailprog $emailuser");

exit(0);</pre>
</blockquote>
<hr />
<h3>OPTIONAL CHAPTERS FROM HERE ON DOWN!<br />
THIS STUFF WILL LIKELY APPLY IF YOU ARE BUILDING A LARGER / MORE COMPLEX SERVER  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </h3>
<hr />
<h3><a name="DEDICATED_AMAVISD_SERVER"></a>DEDICATED AMAVISD SERVER</h3>
<p>It is possible to put the amavisd/clamav/spamassassin on a different  box to the Postfix. This can be advantageous as although the clamav software  doesn&#8217;t consume many resources, the SpamAssassin software can create quite a heavy  load.</p>
<p>ON THE POSTFIX MACHINE :</p>
<blockquote><p>Add an entry in the firewall that permits your amavisd machine to connect      on port TCP 10025 ( Amavisd )</p>
<p>Add an entry in the firewall that permits your amavisd machine to connect      on port TCP 3306 ( MySQL )</p>
<p>Allow MySQL to serve lookups to the 2nd machine</p>
<blockquote>
<pre>GRANT SELECT ON postfix.* TO postfixuser@<strong>offload-machines-address-here</strong> IDENTIFIED BY 'postfixpass';</pre>
</blockquote>
<p>Modify the MySQL so it listens for TCP connections</p>
<blockquote>
<pre>vi /etc/my.cnf</pre>
<blockquote>
<pre>#skip-networking</pre>
</blockquote>
</blockquote>
<p>In the /etc/postfix/main.cf, reconfigure Postfix to send the amavisd      traffic to the amavisd machine</p>
<blockquote>
<pre>content_filter=smtp-amavis:[<strong>offload-machines-fdqn-hostname-here</strong>]:10024</pre>
<p># Note you could have multiple machines setup eg      avs1/2/3/4.<font color="#ff0000">yourdomain.com</font>,<br />
# and a round-robin DNS name of avs.<font color="#ff0000">yourdomain.com</font> that points to these      boxes,<br />
# and you could use that avs.<font color="#ff0000">yourdomain.com</font> hostname in that command above.<br />
# This will loadshare the amavisd traffic amongst your multiple servers</p></blockquote>
<p>In the /etc/postfix/main.cf, reconfigure Postfix to listen for amavisd      traffic from the amavisd machine</p>
<blockquote>
<pre><strong>192.168.1.10</strong>:10025 inet n - n - - smtpd-av
  -o content_filter=
  -o smtpd_restriction_classes=
  -o smtpd_delay_reject=no
  -o smtpd_client_restrictions=permit_mynetworks,reject
  -o smtpd_helo_restrictions=
  -o smtpd_sender_restrictions=
  -o smtpd_recipient_restrictions=permit_mynetworks,reject
  -o smtpd_data_restrictions=reject_unauth_pipelining
  -o smtpd_end_of_data_restrictions=
  -o mynetworks=<strong>offload-machines-ip-or-subnet-here</strong>
  -o smtpd_error_sleep_time=0
  -o smtpd_soft_error_limit=1001
  -o smtpd_hard_error_limit=1000
  -o smtpd_client_connection_count_limit=0
  -o smtpd_client_connection_rate_limit=0
  -o smtpd_milters=
  -o local_header_rewrite_clients=
  -o local_recipient_maps=
  -o relay_recipient_maps=
  -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks,no_address_mappings</pre>
</blockquote>
</blockquote>
<p>ON THE AMAVISD MACHINE :</p>
<blockquote><p>Follow these steps from the top of the guide</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#INSTALL_CENTOS">INSTALL CENTOS</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#TWEAK_THE_CENTOS_INSTALL">TWEAK THE CENTOS INSTALL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#UPDATE_ALL_THE_RPMS">UPDATE ALL THE RPMS</a></li>
</ul>
<p>Add an entry in the firewall that permits mail.<font color="#ff0000">yourdomain.com</font>  	to connect on port 10024</p>
<p>Run these commands</p>
<blockquote>
<pre># Not running MySQL server on this box ( but still want the libraries ).
# Also not running apache.
chkconfig mysqld off
chkconfig httpd off</pre>
<pre># Load postfix from RPM to allow this box to send mail ( nightly reports etc )
yum install postfix system-switch-mail
# Run this next command and choose postfix
system-switch-mail</pre>
<pre># Ensure that you have got prerequisite libraries installed
yum install mysql-devel db4-devel db4-utils zlib zlib-devel</pre>
</blockquote>
<p>Follow the installation steps at the top of the guide for these  	applications :</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#CLAM_ANTIVIRUS">CLAM ANTIVIRUS</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#SPAMASSASSIN">SPAMASSASSIN</a></li>
</ul>
<p>Now follow the amavisd installation steps as shown above except for some  	tweaks shown below</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#AMAVISD">AMAVISD</a></li>
</ul>
<p>In cpan, you might need to &#8220;force install DBD::mysql&#8221;, otherwise it wont      work because the installer tries to test a connection to the local MySQL      server ( which may not succeed since our design wont need MySQL running on      the amavisd machine )</p>
<p>In the /etc/amavisd.conf, you will need to alter these settings :</p>
<blockquote>
<pre>$forward_method = 'smtp:*:*';</pre>
<pre>@inet_acl = qw(127.0.0.0/8 [::1] 192.168.1.10); # adjust list as needed
$inet_socket_bind = undef; # bind to all IP interfaces if undef</pre>
<pre>@lookup_sql_dsn = ( ['DBI:mysql:database=postfix;host=mail.<font color="#ff0000">yourdomain.com</font>', 'postfixuser', 'postfixpass'] );</pre>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />Next is  	an optional tweak, which doesn&#8217;t affect the operation of the server, but  	does fix a problem seen when people are reporting spam to 	<a href="http://www.spamcop.net/">SpamCop</a>. By default amavisd calls  	itself localhost in the headers, which is OK when the software is running on  	same box as Postfix. But when you have split the two applications apart onto  	separate boxes, we need to use the proper hostname rather than localhost.  	Unless you make this change SpamCop will trip up on this header and can  	incorrectly identify your mail server as the source of the SPAM.</p>
<p>In the /etc/amavisd.conf, add this line</p>
<blockquote>
<pre>$localhost_name = $myhostname;</pre>
</blockquote>
<p>Probably the best place to put it, is below this line :</p>
<blockquote>
<pre># $myhostname = 'host.example.com'; # fqdn of this host, default by uname(3)</pre>
</blockquote>
</blockquote>
<p>SOME OTHER AMAVISD TIPS :</p>
<p>If you have a really busy  server, then a single amavisd box might not be enough, you might need to run two  or more. Just build them with same config, and setup a round-robin DNS entry  that points to both boxes. Tweak the content_filter line in Postfix&#8217;s main.cf to  use the RR name. Also increase the smtp-amavis_destination_concurrency_limit  setting in main.cf to a suitable amount ( eg if you have 2 dedicated amavisd  machines each configured for 10 clients, then set the  smtp-amavis_destination_concurrency_limit=20)</p>
<p>If you have gone down the        road of splitting the amavisd onto a dedicated box, you are probably on        the lookout for other performance enhancement tips. One suggestion is to        put the amavisd tmp folder into a ram drive. Instructions available here :       <a href="http://www.stahl.bau.tu-bs.de/%7Ehildeb/postfix/amavisd_tmpfs.shtml">       http://www.stahl.bau.tu-bs.de/~hildeb/postfix/amavisd_tmpfs.shtml</a></p>
<p>If you use the        content_filter command in postfix&#8217;s main.cf, you will be scanning all        inbound + outbound mail. If you don&#8217;t want to bother scanning outbound        mail, you remove that content filter line and instead populate your        recipient_access table with a list of locally hosted domains you want to        do filtering for eg :</p>
<blockquote>
<pre>recipient            response
hosteddomain1.com    FILTER smtp-avavis:[amavis-hostname]:10024
hosteddomain2.com    FILTER smtp-avavis:[amavis-hostname]:10024
hosteddomain3.com    FILTER smtp-avavis:[amavis-hostname]:10024</pre>
</blockquote>
<hr />
<h3><a name="HORDE_SUITE"></a>HORDE SUITE</h3>
<p>We already have a webmail package installed ( sqwebmail ). However sqwebmail  only has a very functionality. Many times you will have users who want something  more powerful. This is where the Horde suite can help. Its takes a bit of work  to get it installed, but the results are worth the effort.</p>
<p>Install the prerequisite modules</p>
<blockquote>
<pre>yum install php php-devel php-mysql php-imap php-xml php-mbstring php-gd php-mycrypt enscript</pre>
<pre><code>pear install -o Log Mail Mail_Mime DB Date File Net_URL Net_Sieve Net_Socket HTTP_Request Fileinfo</code></pre>
<pre><span style="background-color:#ffff00;"># Gotcha with above! The Fileinfo tries to compile in /tmp, which our tweaked fstab disallows.
# Workaround is to remove the nosuid,noexec from fstab, and to mount -o remount /tmp before install,
#  and then put it back again afterwards.
# Would be good if we could come up with something more graceful
# eg, can we perhaps export TEMP variable or similar to point other than /TMP for this install</span></pre>
<pre><code># Then I would recommend you run the following to bring all your pear modules up to date</code></pre>
<pre><code>pear upgrade Archive_Tar
pear upgrade PEAR
# If the above command fails saying it requires PEAR-1.3.3, then type "pear upgrade PEAR-1.3.3" and then run above command again
pear channel-update pear.php.net
pear upgrade-all</code></pre>
</blockquote>
<p>Install the optional wvHhtml tool, so IMP can render MS Word docs as HTML :</p>
<blockquote><p>On Fedora you can just do this :</p>
<blockquote>
<pre>yum install wv</pre>
</blockquote>
<p>On CentOS its a bit more work involved, you need to do this :</p>
<blockquote>
<pre>yum install zlib zlib-devel libpng libpng-devel</pre>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/wvware/wv-1.0.3.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/wvware/wv-1.0.3.tar.gz</a>
tar xzf wv-1.0.3.tar.gz
chown -R root.root wv-1.0.3
cd wv-1.0.3
./configure
make
make install</pre>
</blockquote>
</blockquote>
<p>Suitably tweak the PHP configuration</p>
<blockquote>
<pre><code>vi /etc/php.ini</code></pre>
<blockquote>
<pre><code># in the "Dynamic Extensions" part, enter this :
extension=fileinfo.so</code></pre>
<pre><code># find and tweak these values to allow for large webmail uploads
max_execution_time = 3600
memory_limit = 64M
post_max_size = 18M
file_uploads = On
upload_max_filesize = 17M</code></pre>
</blockquote>
<pre><code>killall -HUP httpd</code></pre>
</blockquote>
<p>HORDE APPLICATION FRAMEWORK</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="ftp://ftp.planetmirror.com/pub/horde/horde/horde-3.1.1.tar.gz">ftp://ftp.planetmirror.com/pub/horde/horde/horde-3.1.1.tar.gz</a></pre>
<pre>cd /var/www/mail/html
tar xzf /usr/local/src/horde-3.1.1.tar.gz</pre>
<pre>chown -R root.apache horde-3.1.1
chmod -R o-rwx horde-3.1.1</pre>
<pre>mv horde-3.1.1 horde
cd horde</pre>
<pre>cd scripts/sql
vi create.mysql.sql</pre>
<blockquote>
<pre># change this line :
PASSWORD('hordepass')</pre>
</blockquote>
<pre>mysql -u root &lt; create.mysql.sql
cd ../..</pre>
<pre>cd config
for f in *.dist; do cp $f `basename $f .dist`; done
cd ..</pre>
<pre>chown -R root.apache config
chmod -R g+rw config</pre>
<pre>cd /var/www/mail/html/images
# grab a copy of your logo file needs to be max 140px wide and 40px high
wget http://somewhere/images/<font color="#ff0000">yourdomain.com</font>-smalllogo.gif
# grab a copy of your larger logo file
wget http://somewhere/images/<font color="#ff0000">yourdomain.com</font>-largelogo.gif</pre>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde/test.php</pre>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde/</pre>
<blockquote>
<pre>click on Administration-&gt;Setup</pre>
<blockquote>
<pre>In the Application screen, click on Horde</pre>
<blockquote>
<pre>Database -&gt;</pre>
<blockquote>
<pre>What database backend : MySQL
Request persistent connections : ticked
Database server/host : localhost
Username to connect to the database as : horde
password to connect with : hordepass
database name to use : horde</pre>
</blockquote>
<pre>Preference system -&gt;</pre>
<blockquote>
<pre>Preference driver : SQL Database</pre>
</blockquote>
<pre>DataTree System -&gt;</pre>
<blockquote>
<pre>Backend : SQL Database</pre>
</blockquote>
<pre>Mailer -&gt;</pre>
<blockquote>
<pre>The location of sendmail binary : /usr/sbin/sendmail</pre>
</blockquote>
<pre>Virtual File Storage -&gt;</pre>
<blockquote>
<pre>Backend : SQL Database</pre>
</blockquote>
<pre>Custom sessions handler -&gt;</pre>
<blockquote>
<pre>Sessionhandler : MySQL based sessions</pre>
<pre>Request persistent connections : ticked
Row level locking : ticked
Database server/host : localhost
Username to connect to the database as : horde
password to connect with : hordepass
database name to use : horde</pre>
</blockquote>
<pre>MIME Detection -&gt;</pre>
<blockquote>
<pre>location : /usr/share/misc/magic</pre>
</blockquote>
<pre>Problem Reporting -&gt;</pre>
<blockquote>
<pre>whre should problem reports be sent : support@<font color="#ff0000">yourdomain.com</font></pre>
</blockquote>
<pre>Menu Settings -&gt;</pre>
<blockquote>
<pre>Select applications to be linked to Hordes menu : imp, ingo, kronolith, turba
Display problem reporting link : Never
URL of an image for top of horde menu : /images/yourdomain.com-smalllogo.gif
If logo is displayed, what URL should it link to : www.<font color="#ff0000">yourdomain.com</font></pre>
</blockquote>
<pre>Click on generate horde config</pre>
</blockquote>
</blockquote>
</blockquote>
<p>If you installed the wvHtml package from source ( CentOS ) rather than RPM (  Fedora), then you need to fix the path Horde uses for this tool :</p>
<blockquote>
<pre>vi /var/www/mail/html/horde/config/mime_drivers.php</pre>
<blockquote>
<pre>$mime_drivers['horde']['msword']['location'] = '/usr<strong>/local</strong>/bin/wvHtml';</pre>
</blockquote>
</blockquote>
<p>Now, regardless of whether you are using CentOS or Fedora, there are two  other Horde helper tools &#8220;xlhtml&#8221; and &#8220;ppthtml&#8221; that need to be disabled.  Although these two tools sound useful ( convert Excel and Powerpoint files to  HTML for viewing), you cant get them via Yum and the source fails to compile on  most boxes I have tried. Also there are two other drivers &#8220;webcpp&#8221; and &#8220;srchighlite&#8221;  which are only for fairly obscure use and these tools dont exist on our machine  so we want to disable them as well :</p>
<blockquote>
<pre>vi /var/www/mail/html/horde/config/mime_drivers.php</pre>
<blockquote>
<pre># up towards the top of the file there is a section that looks like this :
$mime_drivers_map['horde']['registered'] = array(
# need to remove the msexcel, mspowerpoint, srchighlite and webcpp entries from this array</pre>
</blockquote>
</blockquote>
</blockquote>
<p>IMP WEBMAIL</p>
<p><a href="http://www.horde.org/imp/">http://www.horde.org/imp/</a></p>
<blockquote>
<pre>cd /usr/local/src
wget <font color="#808080"><a href="ftp://ftp.planetmirror.com/pub/horde/imp/imp-h3-4.1.1.tar.gz">ftp://ftp.planetmirror.com/pub/horde/imp/imp-h3-4.1.1.tar.gz</a></font></pre>
<pre>cd /var/www/mail/html/horde
tar xzf /usr/local/src/imp-h3-4.1.1.tar.gz</pre>
<pre>chown -R root.apache imp-h3-4.1.1
chmod -R o-rwx imp-h3-4.1.1</pre>
<pre>mv imp-h3-4.1.1 imp
cd imp</pre>
<pre>cd config/
for foo in *.dist; do cp $foo `basename $foo .dist`; done</pre>
<pre>vi servers.php</pre>
<blockquote>
<pre># update the IMAP server info. Replace all existing samples with this :</pre>
<pre>$servers['imap'] = array(
    'name' =&gt; 'Courier IMAP Server',
    'server' =&gt; 'localhost',
    'hordeauth' =&gt; false,
    'protocol' =&gt; 'imap/notls',
    'port' =&gt; 143,
    'smtphost' =&gt; 'localhost',
    'realm' =&gt; '',
    'preferred' =&gt; '',
    'dotfiles' =&gt; false,
    'quota' =&gt; array (
        'driver' =&gt; 'courier',
        'params' =&gt; array()
    ),
    'hierarchies' =&gt; array()
);</pre>
</blockquote>
<pre>vi prefs.php</pre>
<blockquote>
<pre>$_prefs['sent_mail_folder'] = array(
    'value' =&gt; 'Sent',</pre>
<pre>$_prefs['drafts_folder'] = array(
 'value' =&gt; 'Drafts',</pre>
<pre>$_prefs['trash_folder'] = array(
 'value' =&gt; 'Trash',</pre>
</blockquote>
<pre>vi header.php</pre>
<blockquote>
<pre>// Add the IP of the remote browser
$_header['X-Originating-IP'] = $_SERVER['REMOTE_ADDR'];</pre>
</blockquote>
<pre>cd ..</pre>
<pre>chown -R root.apache config
chmod -R g+rw config</pre>
<pre>vi templates/login/login.inc</pre>
<blockquote>
<pre>replace</pre>
<pre>  echo _("Username")</pre>
<pre>with</pre>
<pre>  echo _("Email address")</pre>
</blockquote>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde/imp/test.php</pre>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde/</pre>
<blockquote>
<pre>click on Administration-&gt;Setup</pre>
<pre>In the Application menu, click on Mail (imp)</pre>
<pre>External Utilities and Menu</pre>
<blockquote>
<pre>Location of aspell : /usr/bin/aspell</pre>
<pre>Applications that should be linked to IMPs menu : imp, ingo, koronlith, turba</pre>
</blockquote>
<pre>Compose</pre>
<blockquote>
<pre>Should we append the contents of imp/config/trailer.txt : unticked</pre>
<pre>Can the user request a return receipt : unticked</pre>
<pre>send attachments as links : no</pre>
<pre>maximum size of attachments : 17000000</pre>
</blockquote>
<pre>Click on Generate Mail Configuration</pre>
</blockquote>
</blockquote>
<p>TURBA ADDRESS BOOK</p>
<blockquote>
<pre>cd /usr/local/src
wget <font color="#808080"><a href="ftp://ftp.planetmirror.com/pub/horde/turba/turba-h3-2.1.tar.gz">ftp://ftp.planetmirror.com/pub/horde/turba/turba-h3-2.1.tar.gz</a></font></pre>
<pre>cd /var/www/mail/html/horde
tar xzf /usr/local/src/turba-h3-2.1.tar.gz</pre>
<pre>chown -R root.apache turba-h3-2.1
chmod -R o-rwx turba-h3-2.1</pre>
<pre>mv turba-h3-2.1 turba
cd turba</pre>
<pre>cd config/
for foo in *.dist; do cp $foo `basename $foo .dist`; done</pre>
<pre>vi sources.php</pre>
<blockquote>
<pre>remove all sources except the localsql one</pre>
</blockquote>
<pre>cd ..</pre>
<pre>chown -R root.apache config
chmod -R g+rw config</pre>
<pre>cd scripts/sql
mysql horde &lt; turba_objects.mysql.sql
cd ../..</pre>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde/turba/test.php</pre>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde/</pre>
<blockquote>
<pre>click on Administration-&gt;Setup</pre>
<pre>In the Application menu click on Address Book ( turba)</pre>
<blockquote>
<pre>Select any applications that should be linked to turbas menu : imp, ingo, kronolith, turba</pre>
<pre>Name of source for creating new shares : localsql</pre>
</blockquote>
<pre>Click on Generate Address book configuration</pre>
</blockquote>
<pre></pre>
</blockquote>
<p>KRONOLITH CALENDER</p>
<blockquote>
<pre>cd /usr/local/src
wget <font color="#808080"><a href="ftp://ftp.planetmirror.com/pub/horde/kronolith/kronolith-h3-2.1.1.tar.gz">ftp://ftp.planetmirror.com/pub/horde/kronolith/kronolith-h3-2.1.1.tar.gz</a></font></pre>
<pre>cd /var/www/mail/html/horde
tar xzf /usr/local/src/kronolith-h3-2.1.1.tar.gz</pre>
<pre>chown -R root.apache kronolith-h3-2.1.1
chmod -R o-rwx kronolith-h3-2.1.1</pre>
<pre>mv kronolith-h3-2.1.1 kronolith
cd kronolith</pre>
<pre>cd config/
for foo in *.dist; do cp $foo `basename $foo .dist`; done
cd ..</pre>
<pre>chown -R root.apache config
chmod -R g+rw config</pre>
<pre>cd scripts/sql
mysql horde &lt; kronolith.mysql.sql
cd ../..</pre>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde/</pre>
<blockquote>
<pre>click on Administration-&gt;Setup</pre>
<pre>In the Application menu, click on Calendar (Kronolith)</pre>
<blockquote>
<pre>Server name from which reminders are sent : mail.<font color="#ff0000">yourdomain.com</font></pre>
<pre>Email address from which reminders are send : <a href="mailto:reminder@mail.yourdomain.com">reminder@mail.<font color="#ff0000">yourdomain.com</font></a></pre>
<pre>Applications that should be linked to the Konolith menu : imp, ingo, kronolith, turba</pre>
</blockquote>
<pre>Click on Generate Calender Configuration</pre>
</blockquote>
</blockquote>
<p>INGO FILTERS</p>
<blockquote>
<pre>cd /usr/local/src
wget <font color="#808080"><a href="ftp://ftp.planetmirror.com/pub/horde/ingo/ingo-h3-1.1.tar.gz">ftp://ftp.planetmirror.com/pub/horde/ingo/ingo-h3-1.1.tar.gz</a></font></pre>
<pre>cd /var/www/mail/html/horde
tar xzf /usr/local/src/ingo-h3-1.1.tar.gz</pre>
<pre>chown -R root.apache ingo-h3-1.1
chmod -R o-rwx ingo-h3-1.1</pre>
<pre>mv ingo-h3-1.1 ingo
cd ingo</pre>
<pre>cd config/
for foo in *.dist; do cp $foo `basename $foo .dist`; done
cd ..</pre>
<pre>chown -R root.apache config
chmod -R g+rw config</pre>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde/ingo/test.php</pre>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/ingo/</pre>
<blockquote>
<pre>click on Administration-&gt;Setup</pre>
<pre>In the Application menu, click on Filters (Ingo)</pre>
<blockquote>
<pre>Select applictions that should be linked to ingo's menu : imp, ingo, kronolith, turba</pre>
<pre>Click on Generate Filters configuration</pre>
</blockquote>
</blockquote>
</blockquote>
<p>You can optionally add a couple more modules, but on the servers I build, I  don&#8217;t use these extra modules :</p>
<p><font color="#808080">NAG REMINDERS</font></p>
<blockquote>
<pre><font color="#808080">cd /usr/local/src
wget <a href="ftp://ftp.planetmirror.com/pub/horde/nag/nag-h3-2.1.tar.gz"><font color="#808080">ftp://ftp.planetmirror.com/pub/horde/nag/nag-h3-2.1.tar.gz</font></a></font></pre>
<pre><font color="#808080">cd /var/www/mail/html/horde
tar xzf /usr/local/src/nag-h3-2.1.tar.gz</font></pre>
<pre><font color="#808080">chown -R root.apache nag-h3-2.1
chmod -R o-rwx nag-h3-2.1</font></pre>
<pre><font color="#808080">mv nag-h3-2.1 nag
cd nag</font></pre>
<pre><font color="#808080">cd config/
for foo in *.dist; do cp $foo `basename $foo .dist`; done
cd ..</font></pre>
<pre><font color="#808080">chown -R root.apache config
chmod -R g+rw config</font></pre>
<pre><font color="#808080">cd scripts/sql
mysql -p horde &lt; nag.sql
cd ../..</font></pre>
<pre><font color="#808080">http://mail.<font color="#ff0000">yourdomain.com</font>/horde/nag/test.php</font></pre>
<pre><font color="#808080">http://mail.<font color="#ff0000">yourdomain.com</font>/horde/</font></pre>
<blockquote>
<pre><font color="#808080">click on Administration-&gt;Setup</font></pre>
<pre><font color="#808080">In the Application menu, click on Tasks (Nag)</font></pre>
<blockquote>
<pre><font color="#808080">Click on Generate Reminders configuration</font></pre>
</blockquote>
</blockquote>
</blockquote>
<p><font color="#808080">MNEMO NOTES</font></p>
<blockquote>
<pre><font color="#808080">cd /usr/local/src
wget <a href="ftp://ftp.planetmirror.com/pub/horde/mnemo/mnemo-h3-2.1.tar.gz"><font color="#808080">ftp://ftp.planetmirror.com/pub/horde/mnemo/mnemo-h3-2.1.tar.gz</font></a></font></pre>
<pre><font color="#808080">cd /var/www/mail/html/horde
tar xzf /usr/local/src/mnemo-h3-2.1.tar.gz</font></pre>
<pre><font color="#808080">chown -R root.apache mnemo-h3-2.1
chmod -R o-rwx mnemo-h3-2.1</font></pre>
<pre><font color="#808080">mv mnemo-h3-2.1 mnemo
cd mnemo</font></pre>
<pre><font color="#808080">cd config/
for foo in *.dist; do cp $foo `basename $foo .dist`; done
cd ..</font></pre>
<pre><font color="#808080">chown -R root.apache config
chmod -R g+rw config</font></pre>
<pre><font color="#808080">cd scripts/sql
mysql -p horde &lt; mnemo.sql
cd ../..</font></pre>
<pre><font color="#808080">http://mail.<font color="#ff0000">yourdomain.com</font>/horde/mnemo/test.php</font></pre>
<pre><font color="#808080">http://mail.<font color="#ff0000">yourdomain.com</font>/horde/</font></pre>
<blockquote>
<pre><font color="#808080">click on Administration-&gt;Setup</font></pre>
<pre><font color="#808080">In the Application menu, click on Notes (Mnemo)</font></pre>
<blockquote>
<pre><font color="#808080">Click on Generate Notes configuration</font></pre>
</blockquote>
</blockquote>
</blockquote>
<p>Now that all the modules are installed and setup, lets reconfigure the    Horde module to authenticate users via IMP</p>
<blockquote>
<pre>http://mail.<font color="#ff0000">yourdomain.com</font>/horde</pre>
<blockquote>
<pre>Clock on Administration -&gt; Setup</pre>
<pre>In the Application menu, click on Horde</pre>
<blockquote>
<pre>Authentication -&gt;</pre>
<blockquote>
<pre>Which users should be treated as administrators : <a href="mailto:someadminemail@yourdomain.com">someadminemail@<font color="#ff0000">yourdomain.com</font></a><font color="#ff0000">
</font># NOTE, the address above should be a valid email account that will be hosted on this box.
# When you login into webmail as this user, you will be given access to all the admin
# menus which lets you change the config of the horde suite.</pre>
<pre>What backend for authenticating : let a horde application handle authentication</pre>
<pre>The application that is providing authentication : imp</pre>
<pre>Click on Generate Horde Configuration</pre>
<pre>you get a nasty forbidden message at this point, because you have just killed off the previous administrator user admin rights</pre>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<p>And lets tweak the interface defaults a bit</p>
<blockquote>
<pre>vi /var/www/mail/html/horde/templates/common-footer.inc</pre>
<blockquote>
<pre># Add this to the top of the file</pre>
<pre>&lt;!-- CUSTOM BRANDING TWEAKS --&gt;
&lt;p&gt;&lt;center&gt;&lt;b&gt;<font color="#ff0000">yourdomain.com</font> support - call 1300 xxx xxx&lt;/b&gt;&lt;/center&gt;&lt;/p&gt;
&lt;!-- CUSTOM BRANDING TWEAKS --&gt;</pre>
</blockquote>
<pre>vi /var/www/mail/html/horde/config/prefs.php</pre>
<blockquote>
<pre>$_prefs['language'] = array(
'value' =&gt; 'en_GB',</pre>
<pre>$_prefs['timezone'] = array(
'value' =&gt; 'Australia/Melbourne',</pre>
<pre><font color="#ff0000">$_prefs['date-format'] = array (
    'value' =&gt; '%Y-%m-%d',</font></pre>
<pre>$_prefs['show_sidebar'] = array (
    'value' =&gt; false,</pre>
<pre>$_prefs['initial_application'] = array(
    'value' =&gt; 'imp',</pre>
</blockquote>
<pre>vi /var/www/mail/html/horde/imp/login.php</pre>
<blockquote>
<pre>#Replace this line</pre>
<pre>// $title = sprintf(_("Welcome to %s"), $registry-&gt;get('name', ($imp_auth) ? 'horde' : null));</pre>
<pre>#With this line</pre>
<pre>$title = sprintf(_("%s Webmail"), _(preg_replace('/^mail\.|^webmail\./', '', $GLOBALS['_SERVER']['SERVER_NAME'])) );</pre>
</blockquote>
<pre>vi /var/www/mail/html/horde/imp/config/motd.php</pre>
<blockquote>
<pre># replace the existing table with</pre>
<pre>&lt;table width="100%"&gt;&lt;tr&gt;&lt;td align="center"&gt;&lt;img src="/images/<font color="#ff0000">yourdomain.com</font>-largelogo.gif" alt="<font color="#ff0000">yourdomain.com</font>" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</pre>
</blockquote>
<pre>vi /var/www/mail/html/horde/imp/config/prefs.php</pre>
<blockquote>
<pre>$_prefs['purge_trash'] = array(
'value' =&gt; 1,</pre>
<pre>$_prefs['purge_trash_interval'] = array(
 'value' =&gt; '3',</pre>
<pre>$_prefs['purge_trash_keep'] = array(
'value' =&gt; 7,</pre>
<pre>$_prefs['fetchmail_menu'] = array(
'value' =&gt; 0,</pre>
<pre>$_prefs['mailbox_start'] = array(
'value' =&gt; IMP_MAILBOXSTART_LASTUNSEEN,</pre>
<pre>$_prefs['sortby'] = array(
'value' =&gt; SORTDATE,</pre>
<pre>$_prefs['sortdir'] = array(
'value' =&gt; 1,</pre>
<pre>$_prefs['filter_on_display'] = array(
'value' =&gt; 1,</pre>
</blockquote>
<pre># This next one you can choose whether you do it or not...
# If you add this tweak, then HTML mails will display inline, rather than requiring the user
# to click on the attachment link.
# Displaying inline can be a security issue, however you have to juggle this against
# helpdesk load that you will suffer from users who complain about not being able to read
# their html mail.
vi /var/www/mail/html/horde/imp/config/mime_drivers.php</pre>
<blockquote>
<pre>$mime_drivers['imp']['html']['inline'] = true;</pre>
</blockquote>
<pre>vi /var/www/mail/html/horde/imp/templates/login/login.inc</pre>
<blockquote>
<pre>#Search for input box name="imapuser" add size=32 as property of input box.
#Since the default box is a bit too small and can cause users confusion
#when they arent able to spot typos that have scrolled off the screen</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="DEFAULT_IMAP_POP3_DOMAIN_PER_HOSTNAME"></a>SETTING A DEFAULT IMAP/POP3 DOMAIN PER HOSTNAME</h3>
<p>You can bind multiple IPs to your server (one per domain) and set &#8220;default&#8221;  POP3/IMAP domain for each IP :</p>
<blockquote><p>Probably you first should remove any DEFAULT_DOMAIN entry from the    /usr/local/courier-authlib/etc/authdaemonrc</p>
<pre>vi /usr/local/courier-imap/etc/imapd</pre>
<blockquote>
<pre>TCPDOPTS="-nodnslookup -noidentlookup -access=/usr/local/courier-imap/etc/default-domains.db -accesslocal"</pre>
</blockquote>
<pre>vi /usr/local/courier-imap/etc/pop3d</pre>
<blockquote>
<pre>TCPDOPTS="-nodnslookup -noidentlookup -access=/usr/local/courier-imap/etc/default-domains.db -accesslocal"</pre>
</blockquote>
<pre>vi /usr/local/courier-imap/etc/default-domains</pre>
<blockquote>
<pre># A set of mappings for ip addresses to default domains
# These mappings are used by courier-imap, and courier-pop3d</pre>
<pre>##
## YOU MUST USE A TAB BETWEEN THE IP AND THE RESULT
## SPACES WILL NOT WORK! AUTH WILL FAIL WITH A TEMP ERROR
##</pre>
<pre>192.168.1.101&lt;TAB&gt;allow,DEFDOMAIN=@domain1.com
192.168.1.102&lt;TAB&gt;allow,DEFDOMAIN=@domain2.com
192.168.1.103&lt;TAB&gt;allow,DEFDOMAIN=@domain3.com</pre>
</blockquote>
</blockquote>
<blockquote>
<pre>( cat /usr/local/courier-imap/etc/default-domains; echo "." ) \
| /usr/local/courier-imap/libexec/makedatprog - /usr/local/courier-imap/etc/default-domains.tmp /usr/local/courier-imap/etc/default-domains.db</pre>
</blockquote>
<p>And from my experience, you have to restart courier-imap for the changes      to take effect after making any changes to this file</p>
<blockquote>
<pre>/etc/rc.d/init.d/courier-imap restart</pre>
</blockquote>
<hr />
<h3><a name="DEFAULT_SQWEBMAIL_DOMAIN_PER_HOSTNAME"></a>SETTING A DEFAULT SQWEBMAIL DOMAIN PER HOSTNAME</h3>
<p>You can bind multiple IPs to your server (one per domain) and set a &#8220;default&#8221;  sqwebmail domain for each IP</p>
<p>The  config below would look to see what IP the client connected to, and would  pre-populate the domain name part of the login box</p>
<blockquote>
<pre>vi /usr/local/sqwebmail/etc/logindomainlist</pre>
<blockquote>
<pre># A set of mappings for ip addresses to default domains
domain1.com:192.168.1.101:@
domain2.com:192.168.1.102:@
domain3.com:192.168.1.103:@</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="DEFAULT_SMTP-AUTH_DOMAIN_PER_HOSTNAME"></a>SETTING A DEFAULT SMTP-AUTH  DOMAIN PER HOSTNAME</h3>
<p>When you configure the SASL ( SMTP-AUTH) settings in postfix&#8217;s main.cf, you  can nominate a default domain to use should the SMTP user not supply one (smtpd_sasl_local_domain  = <font color="#ff0000">yourdomain.com</font> ). However when you are hosting  multiple virtual domains on the one box, unless the vast bulk of your users are  from a single domain, you really need a way to append the correct domain.</p>
<p>You can bind multiple IPs to your server (one per domain), and then set the smtpd_sasl_local_domain inside the  master.cf on a per-smtpd instance basis.</p>
<p>eg Change your master.cf from this ( <a href="http://www.bowe.id.au/michael/isp/postfix-server.htm#INSTALL_A_2ND_ETHERNET_IP">as described earlier in doc</a> )</p>
<blockquote>
<pre>127.0.0.1:smtp    inet n - n - 10 smtpd
192.168.1.11:smtp inet n - n - 50  smtpd-mx
   -o smtpd_sasl_auth_enable=no
192.168.1.10:smtp inet n - n - 100 smtpd</pre>
</blockquote>
<p>To something like this :</p>
<blockquote>
<pre>127.0.0.1:smtp    inet n - n - 10 smtpd
192.168.1.11:smtp inet n - n - 50 smtpd-mx
   -o smtpd_sasl_auth_enable=no
192.168.1.101:smtp  inet n - n - 30 smtpd-domain1
   -o smtpd_sasl_local_domain=domain1.com
192.168.1.102:smtp  inet n - n - 30 smtpd-domain2
   -o smtpd_sasl_local_domain=domain2.com
192.168.1.103:smtp  inet n - n - 30 smtpd-domain3
   -o smtpd_sasl_local_domain=domain3.com</pre>
</blockquote>
<p>And don&#8217;t forget to setup your symlinks</p>
<blockquote>
<pre>cd /usr/libexec/postfix
ln -s smtpd smtpd-domain1
ln -s smtpd smtpd-domain2
ln -s smtpd smtpd-domain3</pre>
</blockquote>
<p>Update your reverse DNS entries</p>
<blockquote>
<pre>$ORIGIN 1.168.192.in-addr.arpa.
11	PTR	mail-mx.<font color="#ff0000">yourdomain.com</font>.
101	PTR	mail.domain1.com.
102	PTR	mail.domain2.com.
103	PTR	mail.domain3.com.</pre>
</blockquote>
<hr />
<h3><a name="DEFAULT_PURE-FTPD_DOMAIN_PER_HOSTNAME"></a>SETTING A DEFAULT PURE-FTPD DOMAIN PER HOSTNAME</h3>
<p>You can set a default login doman domain based on the IP address the user has  connected to</p>
<p>Create a IP &lt;-&gt; Domain mapping table :</p>
<blockquote>
<pre>mysql</pre>
<blockquote>
<pre>USE postfix;</pre>
<pre>CREATE TABLE domain_ips (</pre>
<blockquote>
<pre>ip varchar(15) not NULL,
domain varchar(255) NOT NULL,
PRIMARY KEY (ip)</pre>
</blockquote>
<pre>) TYPE=MyISAM COMMENT='IP to Domain mappings for Pure-ftpd';</pre>
<pre>INSERT INTO domain_ips (ip, domain) VALUES ('192.168.1.101', 'domain1.com');
INSERT INTO domain_ips (ip, domain) VALUES ('192.168.1.102', 'domain2.com');
INSERT INTO domain_ips (ip, domain) VALUES ('192.168.1.103', 'domain3.com');</pre>
<pre>quit</pre>
</blockquote>
</blockquote>
<p>Tweak the pure-ftpd config :</p>
<blockquote>
<pre>vi /etc/pureftpd-mysql.conf</pre>
<blockquote>
<pre>MYSQLGetPW SELECT clear_password FROM mailbox WHERE (("\L" LIKE '%@%' AND email = "\L")  OR  ("\L" NOT LIKE '%@%' AND email = CONCAT("\L",'@',(select domain from domain_ips where ip = "\I")))) AND disableftp=0</pre>
<pre>MYSQLGetDir SELECT CONCAT('/var/vmail/',maildir,'public_html') FROM mailbox WHERE (("\L" LIKE '%@%' AND email = "\L")  OR  ("\L" NOT LIKE '%@%' AND email = CONCAT("\L",'@',(SELECT domain FROM domain_ips WHERE ip = "\I")))) and disableftp=0</pre>
<pre>MySQLGetQTASZ SELECT ftpquota FROM mailbox WHERE (("\L" LIKE '%@%' AND email = "\L")  OR  ("\L" NOT LIKE '%@%' AND email = CONCAT("\L",'@',(SELECT domain FROM domain_ips WHERE ip = "\I")))) AND disableftp=0</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="NO_CLEAR_PASSWORDS"></a>WHAT TO DO IF YOU DONT HAVE CLEAR PASSWORDS AVAILABLE</h3>
<p>If you don&#8217;t have clear passwords ( eg you are migrating a server where you  only have /etc/passwd to work with) you have a couple of choices.</p>
<p>First would be to try cracking the passwords. If you get lucky you can crack  a very good percentage of them using a tool like &#8220;<a href="http://www.openwall.com/john/">John  the Ripper password cracker</a>&#8220;.</p>
<p>If you have no luck cracking the passwords then you might need to tweak your  mailserver config as follows :</p>
<p>Mod your SASL config to use courier-authlib (rather than talking to the MySQL  database directly), and to remove CRAM AUTH options ( which require clear  password to be available )</p>
<blockquote>
<pre>vi /usr/lib/sasl2/postfix.conf</pre>
<blockquote>
<pre># replace all the existing commands with this new block :
pwcheck_method: authdaemond
authdaemond_path: /usr/local/courier-authlib/var/spool/authdaemon/socket
mech_list: plain login</pre>
</blockquote>
<table style="border-collapse:collapse;" border="1" cellpadding="3" cellspacing="3">
<tr>
<td>TIP : If you are using x86_64 platform ( eg Opteron ), this file will        be found in a different place:</p>
<pre>/usr/lib<strong>64</strong>/sasl2/postfix.conf</pre>
</td>
</tr>
</table>
</blockquote>
<p>Add postfix to the daemon group, and tweak the directory permissions    slightly, so that postfix applications can gain access to the courier-authlib    socket</p>
<blockquote>
<pre>usermod -G daemon postfix
chown root.daemon /usr/local/courier-authlib/var/spool</pre>
</blockquote>
<p>Mod your courier-authlib config, so that it doesn&#8217;t try to access the clear  passwords column:</p>
<blockquote>
<pre>vi /usr/local/courier-authlib/etc/authlib/authmysqlrc</pre>
<blockquote>
<pre>#MYSQL_CLEAR_PWFIELD clear_password</pre>
</blockquote>
<pre>/etc/rc.d/init.d/courier-authlib restart</pre>
</blockquote>
<p>Mod your courier-imap/pop3d config to remove any of the CRAM auth options  (which require any clear passwords to be available )</p>
<blockquote>
<pre>vi /usr/local/courier-imap/etc/imapd</pre>
<blockquote>
<pre>IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA AUTH=PLAIN AUTH=LOGIN IDLE"</pre>
</blockquote>
<pre>vi /usr/local/courier-imap/etc/pop3d</pre>
<blockquote>
<pre>POP3AUTH="PLAIN LOGIN"</pre>
</blockquote>
<pre>/etc/rc.d/init.d/courier-imap restart</pre>
</blockquote>
<p>Mod your pure-ftpd config to look at your crypted password data, rather than  clear password data:</p>
<blockquote>
<pre>vi /etc/pureftpd-mysql.conf</pre>
<blockquote>
<pre>MYSQLCrypt any</pre>
<pre># and then go to the MYSQLGetPW line and change any reference of clear_password to password</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="HOSTING_MULTIPLE_SSL_DOMAINS"></a>HOSTING MULTIPLE SSL DOMAINS FOR COURIER-IMAP/POP3D</h3>
<p>Each hostname must have a dedicated IP address</p>
<p>Create a PEM file per hostname.</p>
<p>Save each of them to /usr/local/ssl as</p>
<blockquote>
<pre>$CERTFILE.192.168.1.101
$CERTFILE.192.168.1.102
$CERTFILE.192.168.1.103</pre>
</blockquote>
<p>Where $CERTFILE is the name you used for the $CERTFILE setting in imapd-ssl  and pop3d-ssl conf files</p>
<p>Courier will look for a certfile with matching ip. If it doesn&#8217;t find one, it  will fallback to trying to use &#8220;somecert&#8221;</p>
<hr />
<h3><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" /><a name="HELO_FILTERING_FOR_POSTFIX"></a>HELO  FILTERING FOR POSTFIX</h3>
<p>We have found that spammers will often forge the SMTP HELO address when they  make a connection to Postfix. It seems fairly common for them to use the  hostname or IP address of your server.</p>
<p>To block such spam, first create a list of hostnames and IPs used by your  server :</p>
<blockquote>
<pre>vi /etc/postfix/helo.access</pre>
<blockquote>
<pre>## Deny connections from people forging our hostnames
mail.<font color="#ff0000">yourdomain.com</font>		REJECT You are not me
mail-mx.<font color="#ff0000">yourdomain.com</font>		REJECT You are not me</pre>
<pre>mail.domain1.com		REJECT You are not me
mail.domain2.com		REJECT You are not me
mail.domain3.com		REJECT You are not me</pre>
<pre>domain1.com			REJECT Use of that helo name is not permitted
domain2.com			REJECT Use of that helo name is not permitted
domain3.com			REJECT Use of that helo name is not permitted</pre>
<pre>## Deny connections from people forging our IP
192.168.1.10			REJECT You are not me
192.168.1.11			REJECT You are not me
192.168.1.101			REJECT You are not me
192.168.1.102			REJECT You are not me
192.168.1.103			REJECT You are not me</pre>
</blockquote>
<pre>postmap /etc/postfix/helo.access</pre>
</blockquote>
<p>Then tell Postfix to do helo filtering (if you uncomment the warn_if_reject  line, hits will be logged but not actually rejected &#8211; which can be good for  initial testing ) :</p>
<blockquote>
<pre>vi /etc/postfix/main.cf</pre>
<blockquote>
<pre>smtpd_helo_required = yes
smtpd_helo_restrictions =
	permit_mynetworks,
	check_helo_access hash:/etc/postfix/helo.access,
	# warn_if_reject,
	reject_invalid_helo_hostname,
	permit</pre>
</blockquote>
<pre>postfix reload</pre>
</blockquote>
<p>To check for hits, try</p>
<blockquote>
<pre>tail -f /var/log/maillog | grep "Helo command rejected"</pre>
</blockquote>
<p>The RFC&#8217;s state that you aren&#8217;t meant to reject mail based on the data  presented in the helo command, however after much analysis of our logs we have  found that all the hits we are getting are SPAM. I have yet to see any legit  users be affected by this piece of config, so I am satisfied that it is a safe  and worthwhile mod. If you are unsure, then uncomment the warn_if_reject line  and inspect the results before going live.</p>
<hr />
<h3><img src="http://www.bowe.id.au/images/undercon.gif" border="0" height="38" width="40" /><a name="HOSTING_MULTIPLE_SSL_DOMAINS_FOR_APACHE_/_SQWEBMAIL"></a>HOSTING  MULTIPLE SSL DOMAINS FOR APACHE / SQWEBMAIL</h3>
<hr />
<h3><img src="http://www.bowe.id.au/images/undercon.gif" border="0" height="38" width="40" /><a name="HOSTING_MULTIPLE_SSL_DOMAINS_FOR_POSTFIX"></a>HOSTING  MULTIPLE SSL DOMAINS FOR POSTFIX</h3>
<p>In one of the sections above, I show how to set multiple smtp-auth domains  for Postfix. The same technique can be used to set multiple SSL domains.</p>
<p>Don&#8217;t set a default global SSL domain in in main.cf</p>
<blockquote>
<pre>smtpd_tls_key_file =
smtpd_tls_cert_file =</pre>
</blockquote>
<p>Set use them as -o entries instead in master.cf eg</p>
<blockquote>
<pre>192.168.1.101:smtp  inet n - n - 30 smtpd-domain1
   -o smtpd_tls_key_file=/usr/local/ssl/mail.domain1.com.key
   -o smtpd_tls_cert_file=/usr/local/ssl/mail.domain1.com.crt
192.168.1.102:smtp  inet n - n - 30 smtpd-domain2
   -o smtpd_tls_key_file=/usr/local/ssl/mail.domain2.com.key
   -o smtpd_tls_cert_file=/usr/local/ssl/mail.domain2.com.crt
192.168.1.103:smtp  inet n - n - 30 smtpd-domain3
   -o smtpd_tls_key_file=/usr/local/ssl/mail.domain3.com.key
   -o smtpd_tls_cert_file=/usr/local/ssl/mail.domain3.com.crt</pre>
</blockquote>
<p><span style="background-color:#ffff00;">HAVE TO TEST THIS STILL</span></p>
<hr />
<h3><img src="http://www.bowe.id.au/images/undercon.gif" border="0" height="38" width="40" /><a name="WHAT_TO_DO_IF_YOU_DONT_WANT_TO_USE_SSL"></a>WHAT  TO DO IF YOU DONT WANT TO USE SSL</h3>
<p>Some mail servers will not need SSL functionality enabled. Usually due cost  savings that can be made particularly if you are hosting a large number of  domains. You can self-sign certs, but that is usually only suitable for testing.  In production your users will complain about the security warnings generated by  their mail client / web browser.</p>
<p>Disable SSL in Postfix</p>
<blockquote>
<pre>vi /etc/postfix/master.cf</pre>
<blockquote><p>remark out the smtps service (and any associated -o arguments)</p></blockquote>
<pre>vi /etc/postfix/main.cf</pre>
<blockquote>
<pre>smtpd_use_tls = no</pre>
</blockquote>
<pre>postfix reload</pre>
</blockquote>
<p>Disable SSL in courier-imap / courier-pop3d</p>
<blockquote>
<pre>vi /usr/local/courier-imap/etc/imapd-ssl</pre>
<blockquote>
<pre>IMAPDSSLSTART=NO
IMAPDSTARTTLS=NO</pre>
</blockquote>
</blockquote>
<blockquote>
<pre>vi /usr/local/courier-imap/etc/imapd-ssl</pre>
<blockquote>
<pre>POP3DSSLSTART=NO
POP3_STARTTLS=NO</pre>
</blockquote>
<pre>/etc/rc.d/init.d/courier-imap restart</pre>
</blockquote>
<p>Disable SSL in Apache</p>
<blockquote><p><span style="background-color:#ffff00;">INSTRUCTIONS TO BE ADDED</span></p></blockquote>
<hr />
<h3><img src="http://www.bowe.id.au/images/undercon.gif" border="0" height="38" width="40" /> <a name="FUZZYOCR"></a>FUZZYOCR</h3>
<p><a href="http://fuzzyocr.own-hero.net/wiki/Downloads"> http://fuzzyocr.own-hero.net/wiki/Downloads</a></p>
<p>This is a plugin for SpamAssassin that uses OCR tools to grab the words from  inside those annoying image-based spams</p>
<p>NOTE : I have been tinkering with this on a few different machines. It seems  to run OK on machines that have only light load, but when I try to run it on  some of our busier equipment, I am seeing problems with crashed spamd or amavisd  processes. Have tried tinkering with different package versions, patches, source  vs RPM install without much success. So it seems the concept is a good one, but  maybe we wont be able to use it in busy production environment until some new  builds of the software are available.</p>
<p>Install gifsicle application ( a tool which we will use to get info about  GIFs )</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://www.lcdf.org/gifsicle/gifsicle-1.44.tar.gz">http://www.lcdf.org/gifsicle/gifsicle-1.44.tar.gz</a>
tar xzf gifsicle-1.44.tar.gz
chown -R root.root gifsicle-1.44
cd gifsicle-1.44
./configure --disable-gifview
make
make install</pre>
</blockquote>
<p>Install gOCR prerequisite modules, which do things like convert gif/jpg/png/tiff  to pbm format</p>
<blockquote>
<pre># Tools to convert gif/jpg/png/tiff files to pnm "portable anymaps" format
yum install netpbm netpbm-progs netpbm-devel</pre>
<pre># Now we need to install some more tools :
# * giffix tool which allows us to intentionally corrupted GIFs
# * giftext tool which dumps text info about a GIF file ( which has a bug and needs to be patched )
# Although these are available as RPM's, we cant use them as the giftext program contains
# a bug which can cause segfaults. So instead we need to grab the source, patch it and then
# compile/install</pre>
<pre>yum remove libungif libungif-progs</pre>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/libungif/giflib-4.1.4.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/libungif/giflib-4.1.4.tar.gz</a>
tar xzf giflib-4.1.4.tar.gz
chown -R root.root giflib-4.1.4
cd giflib-4.1.4</pre>
<pre>cd util
wget <a href="http://users.own-hero.net/%7Edecoder/fuzzyocr/giftext-segfault.patch">http://users.own-hero.net/~decoder/fuzzyocr/giftext-segfault.patch</a>
patch &lt; giftext-segfault.patch
cd ..</pre>
<pre>./configure
make
make install</pre>
</blockquote>
<p>Install the gOCR application (which reads pnm archives)</p>
<blockquote>
<pre># grab the gOCR source ( FuzzyOcr author recommends 0.40, not 0.41)
cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/jocr/gocr-0.41.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/jocr/gocr-0.40.tar.gz</a>
tar xzf gocr-0.40.tar.gz
chown -R root.root gocr-0.40
cd gocr-0.40</pre>
<pre># Apply patch for a bug thats been identified
wget <a href="http://users.own-hero.net/%7Edecoder/fuzzyocr/gocr-segfault.patch">http://users.own-hero.net/~decoder/fuzzyocr/gocr-segfault.patch</a>
patch -p0 &lt; gocr-segfault.patch</pre>
<pre>./configure</pre>
<pre># TIP: On CentOS, but not Fedora, the configure script experiences a failed dependency on the maths library,
# which causes the netpbm libraries to be rejected :
#     <em>checking for library containing pnm_readpnminit... no</em>
#     <em>* * * try option --with-netpbm=PATH</em>
# The workaround is to use this command instead :
./configure LIBS=-lm</pre>
<pre>make
make install</pre>
</blockquote>
<p>Install the ocradd application ( which reads pbm formats, and outputs text.  Its similar to gOCR, and can be used to give &#8220;2nd opinion&#8221;)</p>
<blockquote>
<pre># Some of the boxes I was experimenting with needed this
# (although I assume it should already been installed if you ticked development tools as per my doco)
yum install gcc-c++</pre>
<pre>cd /usr/local/src
wget <a href="ftp://gnu.mirror.pacific.net.au/gnu/gnu/ocrad/ocrad-0.16.tar.bz2">ftp://gnu.mirror.pacific.net.au/gnu/gnu/ocrad/ocrad-0.16.tar.bz2</a>
tar xjf ocrad-0.16.tar.bz2
chown -R root.root ocrad-0.16
cd ocrad-0.16
./configure
make
make install</pre>
</blockquote>
<p>Install some perl modules used by the FuzzyOcr SpamAssassin plugin</p>
<blockquote>
<pre>perl -MCPAN -e shell
  o conf prerequisites_policy follow
  install String::Approx MLDBM
  quit</pre>
</blockquote>
<p>Install the FuzzyOcr plugin for SpamAssassin</p>
<blockquote>
<pre># grab the source
cd /usr/local/src
wget <a href="http://users.own-hero.net/%7Edecoder/fuzzyocr/fuzzyocr-3.4.2-devel.tar.gz">http://users.own-hero.net/~decoder/fuzzyocr/fuzzyocr-3.4.2-devel.tar.gz</a>
tar xzf fuzzyocr-3.4.2-devel.tar.gz
chown -R root.root FuzzyOcr-3.4.2</pre>
<pre>cd FuzzyOcr-3.4.2</pre>
<pre>cp FuzzyOcr.pm /etc/mail/spamassassin
cp FuzzyOcr.cf /etc/mail/spamassassin</pre>
<pre>echo "### MAKE SURE YOU DONT PUT ANY BLANK LINES IN HERE ###" &gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "###" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "### * Matches are case insentive" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "### * All special chars, spaces or numbers are stripped before any matching is done" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "### * Your wordlist word will be found even if its inside another word ( submatching )" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
cat FuzzyOcr.words.sample &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "goldmark" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "gdki" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "l intl computers inc" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "metropolis technologies" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words
echo "### MAKE SURE YOU DONT PUT ANY BLANK LINES IN HERE ###" &gt;&gt; /etc/mail/spamassassin/FuzzyOcr.words</pre>
<pre>touch /etc/mail/spamassassin/FuzzyOcr.log
chown clamav.clamav /etc/mail/spamassassin/FuzzyOcr.log</pre>
<pre>touch /etc/mail/spamassassin/FuzzyOcr.db
chown clamav.clamav /etc/mail/spamassassin/FuzzyOcr.db</pre>
<pre>touch /etc/mail/spamassassin/FuzzyOcr.safe.db
chown clamav.clamav /etc/mail/spamassassin/FuzzyOcr.safe.db</pre>
<pre>vi /etc/mail/spamassassin/FuzzyOcr.cf</pre>
<blockquote>
<pre>focr_logfile /etc/mail/spamassassin/FuzzyOcr.log</pre>
<pre>focr_bin_gifsicle /usr<strong>/local</strong>/bin/gifsicle
focr_bin_giffix /usr<strong>/local</strong>/bin/giffix
focr_bin_giftext /usr<strong>/local</strong>/bin/giftext
focr_bin_gifinter /usr<strong>/local</strong>/bin/gifinter
focr_bin_gocr /usr<strong>/local</strong>/bin/gocr
focr_bin_ocrad /usr<strong>/local</strong>/bin/ocrad</pre>
<pre>focr_scansets $gocr -i $pfile, $gocr -l 180 -d 2 -i $pfile, $ocrad <strong>-s5</strong> -T 0.5 $pfile</pre>
<pre>focr_threshold 0.2</pre>
<pre>focr_add_score 0.25
focr_counts_required 3</pre>
<pre>focr_enable_image_hashing 2
focr_db_hash /etc/mail/spamassassin/FuzzyOcr.db
focr_db_safe /etc/mail/spamassassin/FuzzyOcr.safe.db</pre>
</blockquote>
</blockquote>
<p>Test to see if your installation is working properly :</p>
<blockquote>
<pre>cd samples
spamassassin -t &lt; png.eml
spamassassin -t &lt; jpeg.eml
spamassassin -t &lt; animated-gif.eml
spamassassin -t &lt; corrupted-gif.eml</pre>
</blockquote>
<p>If you have been running Amavisd/Spamassassin for a while before installing  this plugin, I think its a good idea to zap your existing auto-whitelist and  bayes database files so that they will be rebuilt more accurately now we have  OCR capabilities :</p>
<blockquote>
<pre>/etc/rc.d/init.d/amavisd stop
cd ~clamav/.spamassassin
rm *
/etc/rc.d/init.d/amavisd start</pre>
</blockquote>
<hr />
<h3><a name="MISC_NOTES"></a>MISC NOTES :</h3>
<ul>
<li>There is no fancy GUI interface available for managing accounts. With my   <a href="http://www.bowe.id.au/michael/isp/webmail-server.htm">Qmail guide</a> there was a handy program called   <a href="http://www.inter7.com/?page=qmailadmin">QmailAdmin</a>. In the    Postfix world it seems that <a href="http://high5.net/postfixadmin/">   Postfix.Admin</a> is popular. ( Note : my database design isn&#8217;t exactly the same as the one for PostfixAdmin ). At my workplace we have written our own perl-based CGI scripts for adding/removing/modifying mailboxes.</li>
</ul>
<hr />
<h3><strong><a name="TODO"></a>TODO :</strong></h3>
<ul>
<li>Describe how to build a secondary MX machine which uses the mysql data  	to be able to validate all recipient addresses</li>
<li>Maybe set smtpd_sasl_auth_enable=no in main.cf, and enable only on the  	required customer-smtpd services in master.cf  ?</li>
<li>Provide more explanation about what each database table / column is used  	for. Include some examples showing how to make use of the amavisd-related  	columns.</li>
<li>Describe these log entries : <font face="Arial" size="2"> 	<span style="font-size:10pt;font-family:Arial;font-style:italic;"> 	lookup_sql_field(id) (WARN: no such field in the SQL table), &#8220;admin@mydomain.com&#8221;  	result=undef</span></font></li>
<li>Can add rebuilt &#8216;Fedora &#8211; Extras&#8217; repo to CentOS 	<a href="http://centos.karan.org/">http://centos.karan.org/</a>, which would  	allow RPM versons of wv, arc, cabextract, zoo,  freeze, pure-ftpd</li>
<li>Add some Postfix examples for smtpd_client_connection_count|rate_limit, smtpd_client_message|recipient_rate_limit</li>
<li>Create a sysv script with chkconfig support for sqwebmail</li>
<li>Implement the amavisd black/whitelist functionality</li>
<li>Find a solution to the &#8220;pear install&#8221; where it wants to exec programs on    the /tmp</li>
<li>When you have a virtual alias domain mapping @domain1.com a virtual    mailbox domain @domain2.com, it appears postfix is accepting any address on    domain1, but it doesn&#8217;t then immediately bounce the mail if it doesn&#8217;t exist on    domain2. It first sends the mail via the content_filter and the message only    gets bounced once maildrop tries to lookup the destination maildir. Need to    see if we can optimise this a bit.</li>
</ul>
<hr />
<p align="right"><a href="http://www.bowe.id.au/michael/isp/default.htm">Back to Michael&#8217;s ISP Links page</a></p>
<p align="left">Last updated <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d-%b-%Y" startspan -->03-May-2007<!--webbot bot="Timestamp" i-checksum="16014" endspan --><br />
<strong><a href="mailto:mbowe@pipeline.com.au"><font size="4">Please send me your feedback!</font></a></strong></p>
<hr />
<p align="center"><!-- google_ad_client = "pub-4778638820405329"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text"; google_ad_channel =""; google_color_border = "336699"; google_color_bg = "FFFFFF"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "008000"; //-->  </p>
<hr />
<h3 align="left">ChangeLog :</h3>
<p align="left">3rd May :</p>
<ul>
<li>
<p align="left">Upgrade to SpamAssassin 3.2.0</p>
</li>
</ul>
<p align="left">2nd May :</p>
<ul>
<li>
<p align="left">Upgrade to Postfix 2.4.1</p>
</li>
<li>
<p align="left">Upgrade to Courier-Authlib 0.59.3</p>
</li>
<li>
<p align="left">Upgrade to Maildrop 2.0.4</p>
</li>
<li>
<p align="left">Upgrade to Courier-IMAP 4.1.3</p>
</li>
<li>
<p align="left">Upgrade to SqWebMail 5.1.6</p>
</li>
</ul>
<p align="left">24th April :</p>
<ul>
<li>
<p align="left">Upgraded to Amavisd v2.5.0</p>
</li>
</ul>
<p align="left">13th April :</p>
<ul>
<li>
<p align="left">Upgraded to ClamAV 0.90.2</p>
</li>
</ul>
<p align="left">2nd April :</p>
<ul>
<li>
<p align="left">Show how to disable imap service reporting from logwatch  	scripts</p>
</li>
<li>
<p align="left">Upgraded to Postfix 2.4.0</p>
</li>
</ul>
<p align="left">19th March :</p>
<ul>
<li>
<p align="left">Updated to Postfix 2.3.8</p>
</li>
<li>
<p align="left">Changed CentOS 4.3 to 4.4</p>
</li>
</ul>
<p align="left">15th March :</p>
<ul>
<li>
<p align="left">Added &#8220;parent_domain_matches_subdomains =&#8221; to the postfix  	main.cf to allow for less confusion in access maps : &#8220;somedomain.com&#8221; will  	match only that domain and &#8220;<strong>.</strong>somedomain.com&#8221; will match subdomains.</p>
</li>
<li>
<p align="left">Added modified_by and server columns to Postfix MySQL  	tables. On my installs modified_by will contain persons name etc, or scripts  	name that modified the entry last. The server column is going to be used by  	me for some MySQL replication testing for clusters of mailservers</p>
</li>
</ul>
<p align="left">5th March :</p>
<ul>
<li>
<p align="left">Update to ClamAV 0.90.1</p>
</li>
</ul>
<p align="left">19th February :</p>
<ul>
<li>
<p align="left">Added webnodsn=1 to courier-authlib config.</p>
</li>
</ul>
<p align="left">14th February :</p>
<ul>
<li>
<p align="left">Upgraded to ClamAV 0.90</p>
</li>
<li>
<p align="left">Upgraded to SpamAssassin 3.1.8</p>
</li>
</ul>
<p align="left">9th February :</p>
<ul>
<li>
<p align="left">Added a tip about reducing the logging levels for sqlgrey on  	busy servers</p>
</li>
</ul>
<p align="left">7th February :</p>
<ul>
<li>
<p align="left">Moved the no_address_mappings setting from Postfix main.cf  	to master.cf, so that amavisd sees the after-virtual-alias-expansion address  	rather than the before-virtual-alias-expansion address. This is important  	because amavisd is doing lookups against the mailbox table to extract  	per-user antispam/antivirus settings. The email addresses stored in the  	mailbox table will only match correctly once virtual-alias-expansion has  	been done. Eg if you had a virtual alias of  	fred@some-virtual-alias-domain.com which forwards to  	user1@some-virtual-mailbox-domain.com, then you need amavisd to see the  	user1@some-virtual-mailbox-domain.com address, because that is the one that  	is stored in the mailbox table.</p>
</li>
<li>
<p align="left">Removed the smtp-amavis process limit from master.cf and  	replaced it with smtp-amavis_destination_concurrency_limit in main.cf. This  	is important only if you need to exceed a concurrency of 20. Without making  	this change postfix&#8217;s default destination concurrency limit of 20 would cap  	the number of smtp-amavis processes at 20 even if you were setting a higher  	process limit in master.cf. Also added  -o lmtp_connection_timeout=2 to  	the smtp-avamis process in master.cf. Note these changes are really  	important for large installations where multiple dedicated amavisd servers  	are in use.</p>
</li>
</ul>
<p align="left">5th February :</p>
<ul>
<li>
<p align="left">Added at create-missing-softquotas.pl script to allow  	auto-creation of any missing softquota files.</p>
</li>
</ul>
<p align="left">2nd February :</p>
<ul>
<li>
<p align="left">Changes the SNMP / MRTG to monitor LMTP (Postfix -&gt; Amavis)  	rather than smtpd-av (Amavis -&gt; Postfix) processes. The Postfix -&gt; Amavis  	direction is where bottlenecks will show up, not the other direction.</p>
</li>
</ul>
<p align="left">29th January :</p>
<ul>
<li>
<p align="left">Added some notes about setting the Maildrop concurrency in  	Postfix master.cf</p>
</li>
<li>
<p align="left">Added some notes about setting the SMTP-MX concurrency in  	Postfix master.cf</p>
</li>
<li>
<p align="left">Provided some example hardware configs for larger servers</p>
</li>
<li>
<p align="left">Remind people not to forget about adding reverse DNS entries</p>
</li>
<li>
<p align="left">Show how to create a local account for SSH use, and how to  	disable root SSH logins</p>
</li>
<li>
<p align="left">Upgrade Amavis to v2.4.4</p>
</li>
<li>
<p align="left">Upgrade to Postfix v2.3.6</p>
</li>
<li>
<p align="left">Upgrade to ClamAV v0.88.7</p>
</li>
</ul>
<p align="left">25th January 2007 :</p>
<ul>
<li>
<p align="left">Added a note showing how to use /root/.my.cnf</p>
</li>
<li>
<p align="left">Added info showing how to disable Postfix and amavis  	services from being included in the nightly logwatch reports</p>
</li>
<li>
<p align="left">Added Postfix HELO filtering example</p>
</li>
<li>
<p align="left">Disable SMTP-AUTH for Postfix smtpd-mx service</p>
</li>
<li>
<p align="left">Added some preliminary info showing how to host one SSL cert  	per domain in Postfix</p>
</li>
<li>
<p align="left">Added some preliminary info showing how to turn off SSL if  	its not required</p>
</li>
</ul>
<p align="left">15th December :</p>
<ul>
<li>
<p align="left">Added a note about creating a link for /usr/lib/sendmail</p>
</li>
</ul>
<p align="left">6th December :</p>
<ul>
<li>
<p align="left">Added notes to dedicated amavisd server section regarding $localhost_name  	setting</p>
</li>
<li>
<p align="left">Slightly tweaked the rebuild-ftp-softquotas.pl script</p>
</li>
</ul>
<p align="left">27th November :</p>
<ul>
<li>
<p align="left">added spam_lovers_maps and whitelist_sender_maps  to  	/etc/amavisd.conf</p>
</li>
</ul>
<p align="left">7th November :</p>
<ul>
<li>
<p align="left">Update to Postfix-2.3.4</p>
</li>
<li>
<p align="left">Update to ClamAV-0.88.6</p>
</li>
</ul>
<p align="left">30th October :</p>
<ul>
<li>
<p align="left">Update to ClamAV-0.88.5</p>
</li>
<li>
<p align="left">Update to SpamAssassin-3.1.7</p>
</li>
</ul>
<p align="left">27th October :</p>
<ul>
<li>
<p align="left">Tweak the postfix/amavisd content-filter docs to use  	improved -o options in the smtpd-av section, and also to specify  	receive_override_options=no_address_mappings in main.cf</p>
</li>
<li>
<p align="left">Added some FuzzyOCR notes. Still trialling this on some live  	servers, but it looks pretty good!</p>
</li>
</ul>
<p align="left">26th October :</p>
<ul>
<li>
<p align="left">Added fix error when trying to create new Turba addressbook.  	(Have to set shares to be localsql in the Turba config screen)</p>
</li>
</ul>
<p align="left">19th September :</p>
<ul>
<li>
<p align="left">Added info about the CentOS fastestmirror plugin for yum</p>
</li>
</ul>
<p align="left">13th September :</p>
<ul>
<li>
<p align="left">Relocated site to new URL</p>
</li>
<li>
<p align="left">Added note column to recipient_access, sender_access,  client_access MySQL tables, to allow optional freeform note to be attached to  entry.</p>
</li>
</ul>
<p align="left">8th September :</p>
<ul>
<li>
<p align="left">Remove &#8220;&#8211;without-db&#8221; configure switch from maildrop. This flag  was preventing some of maildrop&#8217;s autoresponder functionality.</p>
</li>
</ul>
<p align="left">4th September :</p>
<ul>
<li>
<p align="left">Increased the php.ini max_execution_time and memory_limit     values, as the previous ones seemed too small to handle larger      attachment uploads</p>
</li>
<li>
<p align="left">Upgrade to sqwebmail-5.1.3</p>
</li>
<li>
<p align="left">Tweaked the pear commands showing how to upgrade all the      modules</p>
</li>
<li>
<p align="left">Added installation instructions for the wvHtml package which      is used by IMP Webmail. Also show how to disable two other IMP helpers      xlhtml and ppthtml</p>
</li>
</ul>
<p align="left">31st August 2006 :</p>
<ul>
<li>
<p align="left">Added tips to YUM, SASL, Postfix, and PureFTPd for getting x86_64 platform to  work smoothly</p>
</li>
<li>
<p align="left">Upgraded to SpamAssassin 3.1.5, and Postfix 2.3.3</p>
</li>
</ul>
<p align="left">18th August 2006 :</p>
<ul>
<li>
<p align="left">Added the authtest and authenumerate troubleshooting tips for  courier-authlib</p>
</li>
</ul>
<p align="left">8th August 2006 :</p>
<ul>
<li>
<p align="left">Update to SpamAsssassin-3.1.4, ClamAV-0.88.4</p>
</li>
<li>
<p align="left">Showed how you can combine catchall alias entries and virtual  mailbox domains. Requires tweak of Postfix virtual_alias_maps , and addition of  mysql-virtual-mailbox-to-alias-maps.cf file.</p>
</li>
</ul>
<p align="left">4th August 2006 :</p>
<ul>
<li>
<p align="left">Tidied up the Horde logo examples</p>
</li>
<li>
<p align="left">Added some more notes about the admin email address that you  nominate when setting up Horde</p>
</li>
</ul>
<p align="left">1st August 2006 :</p>
<ul>
<li>
<p align="left">Upgraded to Postfix 2.3.2</p>
</li>
<li>
<p align="left">Moved the &#8220;yum install pcre-devel&#8221; back to an earlier position  in the guide, since Postfix can make use of this library when its present</p>
</li>
</ul>
<p align="left">28th July 2006</p>
<ul>
<li>
<p align="left">Upgraded to Postfix 2.3.1. Changes involve adding -DUSE_CYRUS_SASL  to the Postfix make, and then in main.cf :</p>
<ul>
<li>
<p align="left">change smtpd_sasl_application_name to smtpd_sasl_path</p>
</li>
<li>
<p align="left">change reject_invalid_hostname to reject_invalid_helo_hostname</p>
</li>
<li>
<p align="left">adding smtpd_sasl_authenticated_header = yes</p>
</li>
</ul>
</li>
<li>
<p align="left">Upgraded to amavisd 2.4.2</p>
</li>
<li>
<p align="left">Added the wbusexsender=1 option to courier-authlib  DEFAULTOPTIONS, so that sqwebmail will add an X-Sender header to each outgoing  message</p>
</li>
<li>
<p align="left">Added cyrus-sasl-devel to the list of packages to install during  SASL setup. These libraries are needed to allow Postfix to compile</p>
</li>
</ul>
<p align="left">19th July 2006</p>
<ul>
<li>
<p align="left">Fixed error in Courier-Authlib MYSQL_QUOTA_FIELD. ( Need to  concatenate an &#8220;S&#8221; to the quota string )</p>
</li>
<li>
<p align="left">Removed bat and cmd files from the amavisd banned list</p>
</li>
</ul>
<p align="left">14th July 2006</p>
<ul>
<li>
<p align="left">Tweaked the SpamAssassin local.cf to add some info on  trusted_networks setting</p>
</li>
<li>
<p align="left">Cleaned up the example 192.168 IPs to make then consistent  throughout document</p>
</li>
<li>
<p align="left">Added some more explanation of the /etc/maildroprc file</p>
</li>
<li>
<p align="left">Tweaked the httpd logrotate.conf</p>
</li>
<li>
<p align="left">Added examples showing how to add abuse and postmaster to  postfix recipient_access</p>
</li>
</ul>
<p align="left">3rd July 2006</p>
<ul>
<li>
<p align="left">Tweaked the proxy_read_maps so we can can &#8220;proxy:&#8221; the check_<em>client|sender|recipient</em>_access  entries in smtpd_recipient_restrictions</p>
</li>
<li>
<p align="left">Did a bit of tweaking to the apache config, still could do with  a bit more work. Eg demonstrate how to have 1 SSL cert per domain</p>
</li>
<li>
<p align="left">Added some notes explaining how in the example data we are  &#8220;hashing&#8221; the path to the user dirs</p>
</li>
</ul>
<p align="left">29th June 2006</p>
<ul>
<li>
<p align="left">Switched wording to recommend using CentOS. Left notes in saying  that Fedora will also work.</p>
</li>
<li>
<p align="left">Added some debugging notes for Maildrop</p>
</li>
</ul>
<p align="left">22nd June 2006</p>
<ul>
<li>
<p align="left">Added &#8220;AND disableftp=0&#8243; clauses to the Pureftp MySQL select  commands.</p>
</li>
</ul>
<p align="left">15th June 2006 :</p>
<ul>
<li>
<p align="left">Added description of how to set an smtp-auth default domain per  hostname</p>
</li>
</ul>
<p align="left">14th June 2006 :</p>
<ul>
<li>
<p align="left">Exclude MySQL from crontabbed yum updates. On on of my  production serves I saw mysql-4.1.19 shutdown and 4.1.20 not start automatically  after the update. Needless to say, the server doesnt work too well if MySQL is  down!</p>
</li>
<li>
<p align="left">Tweaked some of the wording in the maildrop section. Also  increased the smallmsg size there, to reduce disk I/O at the expense of higher  RAM consumption.</p>
</li>
<li>
<p align="left">Move the &#8220;yum install pcre-devel gamin-devel&#8221; into the courier-authlib  section. Authlib doesnt need these libraries, but others like maildrop do.</p>
</li>
<li>
<p align="left">Added tips about using RR DNS entry for multiple Amavisd boxes.  Also added the tip about using a RAM disk for the amavisd tmp folder. Also the  tip about only content scanning inbound mail</p>
</li>
</ul>
<p align="left">9th June 2006 :</p>
<ul>
<li>
<p align="left">Added notes about removing non-necessary apache modules from  httpd.conf.</p>
</li>
<li>
<p align="left">Tweaked the Horde customisations to show how to display HTML  attachments inline</p>
</li>
</ul>
<p align="left">26th May 2006 :</p>
<ul>
<li>
<p align="left">Update to Amavisd 2.4.1, SpamAssassin 3.1.2</p>
</li>
</ul>
<p align="left">25th May 2006</p>
<ul>
<li>
<p align="left">Update to Courier-IMAP 4.1.1 and SqWebMail 5.1.2</p>
</li>
</ul>
<p align="left">19th May 2006</p>
<ul>
<li>
<p align="left">Initial linking and announcement of the page</p>
</li>
</ul>
<p>   _uacct = &#8220;UAtable align=&#8221;center&#8221; bgcolor=&#8221;#cccccc&#8221; border=&#8221;1&#8243; bordercolor=&#8221;#000000&#8243; cellpadding=&#8221;2&#8243; cellspacing=&#8221;0&#8243; width=&#8221;90%&#8221;pt&gt; &#8216;s ISP Links pagee<!--/a--></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duynam.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duynam.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duynam.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duynam.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duynam.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duynam.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/duynam.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/duynam.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/duynam.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/duynam.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duynam.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duynam.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duynam.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duynam.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duynam.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duynam.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=duynam.wordpress.com&amp;blog=1451871&amp;post=9&amp;subd=duynam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://duynam.wordpress.com/2007/08/13/postfix-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/30af098ae1325ecf0a6301bafc3a5f10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duynam</media:title>
		</media:content>

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/undercon.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/undercon.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/undercon.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/undercon.gif" medium="image" />
	</item>
		<item>
		<title>Qmail</title>
		<link>http://duynam.wordpress.com/2007/08/13/qmail/</link>
		<comments>http://duynam.wordpress.com/2007/08/13/qmail/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 16:48:27 +0000</pubDate>
		<dc:creator>duynam</dc:creator>
				<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://duynam.wordpress.com/2007/08/13/qmail/</guid>
		<description><![CDATA[REDHAT + QMAIL + OPENSSL + APACHE + PHP + MYSQL + VPOPMAIL (with MySQL accounts) + COURIER-IMAP + SQUIRRELMAIL (with MySQL prefs/addrbook), QMAIL-SCANNER + CLAM ANTIVIRUS + SPAMASSASSIN Original of this document is available at http://www.bowe.id.au/michael/isp/webmail-server.htm MAY 2007 &#8211; THIS DOCUMENT IS NO LONGER MAINTAINED. For the last few years I haven&#8217;t done much [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=duynam.wordpress.com&amp;blog=1451871&amp;post=8&amp;subd=duynam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>REDHAT + QMAIL + OPENSSL + APACHE + PHP + MYSQL + VPOPMAIL (with MySQL  accounts) + COURIER-IMAP + SQUIRRELMAIL (with MySQL prefs/addrbook), QMAIL-SCANNER  + CLAM ANTIVIRUS + SPAMASSASSIN</h3>
<p>Original of this document is available at <a href="http://www.bowe.id.au/michael/isp/webmail-server.htm"> http://www.bowe.id.au/michael/isp/webmail-server.htm</a></p>
<hr />
<h3><strong>MAY 2007 &#8211; THIS DOCUMENT IS NO LONGER MAINTAINED.</strong></h3>
<p><strong>For the last few years I haven&#8217;t done much vpopmail work, because the ISP  where I work uses Postfix rather than qmail. I have recently accepted a job  offer from a different ISP and they use Postfix there as well. When I switch to  this new company it will cut the remaining ties I had with customers using my  original qmail/vpopmail design. I haven&#8217;t really done many updates to this guide  over the last couple of years, and now I have decided that no further updates  will be done at all. I thank everyone who has used the guide and sent me  feedback over the years. I have recently published a <a href="http://www.bowe.id.au/michael/isp/postfix-server.htm">Postfix+MySQL</a> guide, and maybe I will do a  Postfix+LDAP guide soon, since this is the combo used at my new place of  employment.</strong></p>
<p><strong>I would recommend people consider <a href="http://www.shupp.org/toaster/"> Bill Shupp&#8217;s vpopmail toaster</a> ( Linux ), or perhaps <a href="http://www.tnpi.biz/internet/mail/toaster.shtml">Matt Simerson&#8217;s  toaster</a> ( FreeBSD )</strong></p>
<hr />
<table style="border-collapse:collapse;" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<h3>NAVIGATION LINKS</h3>
<p>Jump straight to :</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#MYSQL">MySQL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#OPENSSL">OpenSSL</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#APACHE">Apache</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#QMAIL">qmail</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#VPOPMAIL">vpopmail</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#QMAILADMIN">qmailadmin</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#COURIER_IMAP">Courier-IMAP</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#SQUIRRELMAIL">SquirrelMail</a></li>
<li><a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#SPAM_VIRUS">Qmail-Scanner / Clam AntiVirus / SpamAssassin</a></li>
<li> <a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#MISC">Tips &amp; Misc    Notes</a></li>
<li>   <a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#Example_scripts">Some example web-based domain/mailbox navigation scripts</a></li>
<li>   <a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#TODO">To do</a></li>
<li>   <a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#CHANGELOG">ChangeLog</a></li>
</ul>
<hr />
<h3>BEFORE YOU START</h3>
<blockquote>
<p align="left">I would recommend you first learn qmail via   <a href="http://www.lifewithqmail.org/">www.lifewithqmail.org</a>.</p>
<p align="left">Next do a bit of reading about vpopmail servers : <a href="http://shupp.org/toaster/">Bill Shupp&#8217;s    Linux Qmail Toaster</a>, and also  <a href="http://www.qmailrocks.org/">   http://www.qmailrocks.org/</a></p>
<p align="left">Once you have a good grip on all those concepts, come back and    read this doc to learn how you can add MySQL back-ends to vpopmail and    SquirrelMail  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
</blockquote>
</td>
<td><!-- google_ad_client = "pub-4778638820405329"; google_ad_width = 160; google_ad_height = 600; google_ad_format = "160x600_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "336699"; google_color_bg = "FFFFFF"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "008000"; //-->      </td>
</tr>
</table>
<hr />
<h3>WHY USE MYSQL FOR THE VPOPMAIL AND SQUIRRELMAIL BACK-ENDS?</h3>
<blockquote><p>By having all the vpopmail account data stored it MySQL, it allows you to    easily write web based tools (eg in ASP or PHP) that can talk to the database    and then present easy-to-use interface for your support staff to manage the    user accounts.    <a href="http://www.bowe.id.au/michael/isp/webmail-server.htm#Example_scripts">I have included some more info and examples on this    subject at the bottom of this doc</a></p>
<p>You can easily add additional columns to the vpopmail tables to store other    &#8220;per-user&#8221; information without affecting the operation of vpopmail</p>
<p>For a server with many user accounts, you would expect that MySQL would    give faster performance than disk based accounts. Particularly when you have a    large number of users in a given domain. (I haven&#8217;t personally done any    benchmarks on this, and I also have never seen anyone else run such a test,    but you would have to expect that a SQL based backend would scale better than    the file-based cdb backend that qmail/vpopmail uses by default)</p>
<p>If you have a very large number of accounts, vpopmail can be configured to    use MySQL replication and NFS to share the load over over multiple servers</p></blockquote>
<hr />
<h3>ABOUT THESE NOTES</h3>
<blockquote><p>Follow these notes at your own risk&#8230;!</p>
<p>All the commands shown below have been run as root.</p>
<p>I have successfully used these notes to build many Redhat 7.2, 7.3 and 8.0    based servers. People have told me that Redhat 9.0 &amp; Fedora will also work, but you have to be    aware of a few issues :</p>
<ul>
<li>Most of the qmail software and associated utilities will not compile      under RH9 or Fedora, due to conflicts with its new version of glibc. You can get      patches to solve these problems from <a href="http://www.qmail.org/">     www.qmail.org</a>. (Do a search for &#8220;errno&#8221;). The actual link for      the patches is <a href="http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/">     http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/</a></li>
<li>For packages using perl (eg Razor, SpamAssassin), you may need to add an      &#8220;export LANG=en_US&#8221; to your scripts, or alternatively modify the &#8220;/etc/sysconfig/i18n&#8221;      file.</li>
</ul>
</blockquote>
<hr />
<h3><a name="REDHAT"></a>REDHAT 7.2 / 7.3 / 8.0 NOTES</h3>
<p><strong>FIREWALL :</strong></p>
<blockquote><p>The ipchains or iptables firewalling software will usually be installed    during Redhat&#8217;s installation process.</p>
<p>For this server you will need to make sure you have opened access on at    least the following ports :</p>
<ul>
<li>SMTP:TCP</li>
<li>HTTP.TCP</li>
<li>HTTPS:TCP</li>
<li>POP3:TCP</li>
<li>NTP:UDP</li>
</ul>
<p>Note that we arent going to open the IMAP:TCP port, as we are not offering    IMAP services directly to our clients. We will be running an IMAP server, but    the only program talking to it will be the SquirrelMail software which is also    running on this same box.</p>
<p>On Redhat 7.2 / 7.3 (which uses ipchains by default)</p>
<blockquote><p>You can examine/modify the ipchains config by working on the file :</p>
<pre>	/etc/sysconfig/ipchains</pre>
<p>If you make any changes to this file, you will need to restart the      ipchains software :</p>
<pre>	/etc/rc.d/init.d/ipchains restart</pre>
</blockquote>
<p>On Redhat 8.0 (which uses iptables by default)</p>
<blockquote><p>You can examine/modify the iptables config by working on the file :</p>
<pre>	/etc/sysconfig/iptables</pre>
<p>If you make any changes to this file, you will need to restart the      iptables software :</p>
<pre>	/etc/rc.d/init.d/iptables restart</pre>
</blockquote>
</blockquote>
<p><strong>SETUP TIME SYNCHRONISATION :</strong></p>
<blockquote><p>Mail servers need to have their clocks set correctly. If you don&#8217;t have    their time sync&#8217;ed, you can experience strange problems.</p>
<p>Redhat comes with the ntpd package which is easy to setup</p>
<pre>vi /etc/ntp.conf</pre>
<blockquote><p>look for the &#8220;# &#8212; OUR TIMESERVERS &#8212;&#8211;&#8221; section<br />
and then put in the following lines :</p>
<pre>restrict xxx.xxx.xxx.xxx mask 255.255.255.255 nomodify notrap noquery
server xxx.xxx.xxx.xxx</pre>
<p>where xxx.xxx.xxx.xxx is the IP address of your (or your upstream&#8217;s) NTP      server</p></blockquote>
<p>After making the changes, you will need to restart the ntpd service :</p>
<pre>	/etc/rc.d/init.d/ntpd restart</pre>
<p>Use the ntsysv program and make sure the ntpd service is enabled at bootup    time</p></blockquote>
<p><strong>SETUP DNS :</strong></p>
<blockquote><p>For our example, we setup an A record for hostname.<font color="#ff0066">yourdomain.com</font>.     Any domains that we are hosting mail for should have their primary MX pointing    to this host. We also created the following CNAME aliases for this host :    pop3, smtp, webmail</p>
<p>This allows our users to :</p>
<ul>
<li>access SquirrelMail and qmailadmin via http://webmail.<font color="#ff0066">yourdomain.com</font></li>
<li>set their POP3 clients to pop3.<font color="#ff0066">yourdomain.com</font>      for their incoming mail, and smtp.<font color="#ff0066">yourdomain.com</font>      for their outgoing mail</li>
</ul>
<p>IMPORTANT : Never configure a end-user&#8217;s software to reference the hostname    directly. Even though you might start out with just a single box doing all    your email functions, later on you might add other boxes to split the load    onto different machines (eg one to handle all the SMTP mail, the other doing    POP3/IMAP and another again doing WebMail). By setting your client to use the    aliased names, you can add extra boxes and then just update the DNS as appropriate. No    changes will be required on the client&#8217;s computer. Make sure you take my    advice now on this matter. You will thank me for this later!! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p></blockquote>
<p><strong> CHECK YOUR SYSLOG CONFIG :</strong></p>
<blockquote><p>You may find that your mail server logs a lot of entries to the syslog. On    linux you need to be careful of this as there can be a big performance impact.    In particular you should check your /etc/syslog.conf and make sure there is a    &#8220;-&#8221; symbol in front of any files that will be busy eg &#8220;-/var/log/maillog&#8221;. If    you have to add the file, then dont forget to &#8220;killall -HUP syslogd&#8221; so the    changes are picked up. <a href="http://www.postfix.org/LINUX_README.html">Some    more info on this subject here</a></p></blockquote>
<p><strong>(OPTIONAL) UPDATE YOUR KERNEL :</strong></p>
<blockquote><p>RedHat regularly publishes updated versions of the Linux kernel to suit    their various RedHat distributions. To ensure that your server has best    performance and reliability, it is a good idea to regularly upgrade to the    latest available kernel.</p>
<p>RedHat have got some  easy-to-follow instructions online :</p>
<ul>
<li>     <a href="http://www.redhat.com/docs/manuals/linux/RHL-7.2-Manual/custom-guide/kernel.html">     RedHat 7.2 kernel upgrade guide</a></li>
<li>     <a href="http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/custom-guide/ch-kernel.html">     RedHat 7.3 kernel upgrade guide</a></li>
<li>     <a href="http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/custom-guide/ch-kernel.html">     RedHat 8.0 kernel upgrade guide</a></li>
</ul>
</blockquote>
<hr />
<h3><a name="MYSQL"></a>MYSQL</h3>
<p><a href="http://www.mysql.com/">www.mysql.com</a></p>
<p>We will be using MySQL to store all the domain and mailbox account  information for vpopmail. We are also going to use MySQL to store the  SquirrelMail user preferences and address books</p>
<p>Setup an account for the MySQL server to run under :</p>
<blockquote>
<pre>groupadd mysql
useradd -g mysql mysql</pre>
</blockquote>
<p>Go to their website and download the latest binaries to /usr/local/src.   In this example I have  used the file:</p>
<blockquote>
<pre>mysql-max-3.23.57-pc-linux-i686.tar.gz</pre>
</blockquote>
<p>(Note, MySQL v4 has recently been released as &#8220;stable&#8221;, however I am yet to    personally do any vpopmail testing under this new version. I have used MySQL    v4 for other jobs, and have had reports from other people that it works fine    with vpopmail, so if you are keen you should be safe to give MySQL v4 a go    rather than v3)</p>
<p>Unzip / configure the binaries so they get installed to /usr/local/mysql</p>
<blockquote>
<pre>cd /usr/local
tar xzf /usr/local/src/mysql-max-3.23.57-pc-linux-i686.tar.gz
ln -s mysql-max-3.23.57-pc-linux-i686 mysql</pre>
</blockquote>
<p>Run the installation script that creates/verifies all the various system-use  tables etc</p>
<blockquote>
<pre>cd mysql
scripts/mysql_install_db
cd ..</pre>
</blockquote>
<p>Setup permissions on the MySQL dirs</p>
<blockquote>
<pre>chown -R root.mysql mysql-max-3.23.57-pc-linux-i686
chmod -R 640 mysql
chmod -R u+X,g+X mysql
chmod -R ug+x mysql/bin
chmod -R g+w mysql/data
chmod -R u+x mysql/scripts</pre>
</blockquote>
<p>Let the MySQL server know what amount of resources it is allowed to use</p>
<blockquote>
<pre># choose an appropriate config file from the samples provided
cp /usr/local/mysql/support-files/my-medium.cnf /usr/local/mysql/data/my.cnf
# adjust the permissions on the file so that mysql daemon can read the contents
chgrp mysql /usr/local/mysql/data/my.cnf</pre>
</blockquote>
<p>Fire up the server</p>
<blockquote>
<pre>cd /usr/local/mysql
bin/safe_mysqld --user=mysql &amp;</pre>
</blockquote>
<p>At this point the mysql daemons should be running. A good way to verify    this is to use this command :</p>
<blockquote>
<pre>ps axf</pre>
</blockquote>
<p>If all is well, you should be able to see something like this :</p>
<blockquote>
<pre>1073 ? S 0:00 /bin/sh ./bin/safe_mysqld --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/.pid
1117 ? S 0:00  \_ /usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/local/m
1125 ? S 0:00      \_ /usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr/loc
1126 ? S 0:00          \_ /usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr
1143 ? S 0:00          \_ /usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr
1419 ? S 0:00          \_ /usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr
1449 ? S 0:00          \_ /usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr
1471 ? S 0:00          \_ /usr/local/mysql/bin/mysqld --defaults-extra-file=/usr/local/mysql/data/my.cnf --basedir=/usr</pre>
</blockquote>
<p>(If you received errors, look in the file /usr/local/mysql/data/hostname.err for  debugging info)</p>
<p>Next setup a password for the MySQL root user</p>
<blockquote>
<pre>/usr/local/mysql/bin/mysqladmin -u root password '<em>mysql-root-pwd</em>'</pre>
</blockquote>
<p>Configure MySQL so it is running all the time from bootup onwards</p>
<blockquote>
<pre>cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
chmod 744 /etc/rc.d/init.d/mysql</pre>
</blockquote>
<blockquote>
<pre>chkconfig --add mysql</pre>
<p>Then I like to use the <font face="Courier" size="2">ntsysv</font> program    to double-check that mysql is set to launch at boot time</p></blockquote>
<hr />
<h3><a name="OPENSSL"></a>OPENSSL</h3>
<p><a href="http://www.openssl.org/">www.openssl.org</a></p>
<p>This package is optional. It is required if you want your Apache software to  have SSL support. We have used it because we want our WebMail interface to have  SSL functionality for the login screens. If you don&#8217;t want/need SSL support, you  could skip this section</p>
<p>Go to their website and download the latest source to /usr/local/src.   In this example I have  used the file:</p>
<blockquote>
<pre>openssl-0.9.7b.tar.gz</pre>
</blockquote>
<p>Compile source (installs to /usr/local/ssl)</p>
<blockquote>
<pre>cd /usr/local/src
tar xzf openssl-0.9.7b.tar.gz
chown -R root.root openssl-0.9.7b.tar.gz
cd openssl-0.9.7b
./config no-threads -fPIC
make
make install</pre>
</blockquote>
<p>Generate a private key (make a KEY file)</p>
<blockquote>
<pre>cd /usr/local/ssl</pre>
<pre># generate an 1024-bit RSA private key
bin/openssl genrsa -out private/webmail.<font color="#ff0066">yourdomain.com</font>.key 1024
# make sure the permissions on the private dir are tight
chown -R root.root private
chmod -R 600 private
chmod u+X private</pre>
</blockquote>
<p>Generate a certificate signing request (make a CSR file)</p>
<blockquote>
<pre># fill in the X.509 prompts when they appear on the screen
# make sure you put the web site's name into the common name box eg webmail.<font color="#ff0066">yourdomain.com</font>
bin/openssl req -new -key private/webmail<font color="#ff0066">.yourdomain.com</font>.key -out certs/webmail<font color="#ff0066">.yourdomain.com</font>.csr</pre>
<blockquote>
<pre>Country Name (2 letter code) [AU]:AU
State or Province Name (full name) [Some-State]:Your State
Locality Name (eg, city) []:Your City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Your Company Pty Ltd
Organizational Unit Name (eg, section) []:Internet Services
Common Name (eg, your name or your server's hostname) []:webmail<font color="#ff0066">.yourdomain.com</font>
Email Address []:postmaster@<font color="#ff0066">yourdomain.com</font>

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:yoursecretpasswd
An optional company name []:</pre>
</blockquote>
</blockquote>
<p>Get the certificate signed (make a CRT file)</p>
<blockquote><p><span>Get the certificate signed </span>by one of the official signing authorities (eg   <a href="http://www.thawte.com/">Thawte</a>) :</p>
<blockquote><p>Send the webmail<font color="#ff0066">.yourdomain.com</font>.csr file to      a signing authority for processing&#8230;<br />
When they have signed it, copy the signed certificate to <font face="Courier New" size="2">/usr/local/ssl/certs/webmail.<font color="#ff0066">yourdomain.com</font>.crt</font></p></blockquote>
<p>Or alternately, here is how you can sign it yourself so you can do a bit of    testing! :</p>
<blockquote>
<pre>openssl x509 -req -days 30 -in certs/webmail.<font color="#ff0066">yourdomain.com</font>.csr -out certs/webmail.<font color="#ff0066">yourdomain.com</font>.crt -signkey private/webmail.<font color="#ff0066">yourdomain.com</font>.key</pre>
</blockquote>
</blockquote>
<p>A note for the future&#8230;. Eventually you will need to renew your certificate  :</p>
<blockquote><p>If you get your certificate signed by eg Thawte, then after the certificate    period expires (typically 1 year), you will need to renew the certificate</p>
<p>If all the details for your server are still the same as on your original    signing request, then you do not have to submit them a new CSR file. They can    just ask them to &#8220;re-sign&#8221; your existing certificate with an updated expiry date. Before    proceeding with your renewal request, make sure you still have a copy of your    original private key, as the new certificate will require this file.</p>
<p>Alternatively, if any of the details for your server have changed, then you    will need to apply for a new certificate. To do this just follow the original    steps above that show how to create a certificate from scratch. (Thawte will    still only bill you the cheaper renewal rates..)</p>
<p>Thawte will then send you an updated CRT, and all you do is save this over    the top of your original CRT file (<font face="Courier New" size="2">/usr/local/ssl/certs/webmail.</font><font color="#ff0066" face="Courier New" size="2">yourdomain.com</font>.crt), and    then restart the apache server</p></blockquote>
<hr />
<h3><a name="APACHE"></a>APACHE WEB SERVER (WITH MOD_SSL &amp; PHP4 AS DSO MODULES)</h3>
<p><a href="http://httpd.apache.org/">http://httpd.apache.org</a></p>
<p><span style="background-color:#00ff00;">Text with green background is only  required if you are building in support for mod_ssl</span></p>
<p>Uninstall apache if it is installed already</p>
<blockquote>
<pre>rpm -e --nodeps apache</pre>
</blockquote>
<p>Go to their website and download the latest source to /usr/local/src.   In this example I have  used the file:</p>
<blockquote>
<pre>apache_1.3.27.tar.gz</pre>
</blockquote>
<p>(Note, Apache v2 has recently been released as &#8220;stable&#8221;, however I am yet to  do any testing under this new version. I would recommend that you stay with v1.3    until the v2 series is more mature)</p>
<p>Extract the apache source</p>
<blockquote>
<pre>cd /usr/local/src
tar xzf apache_1.3.27.tar.gz
chown -R root.root apache_1.3.27</pre>
</blockquote>
<p>Create an account  and group for the web server to run under</p>
<blockquote>
<pre>groupadd www
useradd -g www www</pre>
</blockquote>
<p><span style="background-color:#00ff00;">Merge in the mod_ssl source</span></p>
<blockquote><p><a href="http://www.modssl.org/"><span style="background-color:#00ff00;">   www.modssl.org</span></a></p>
<p><span style="background-color:#00ff00;">mod_ssl provides SSL cryptography functionality for the Apache webserver</span></p>
<p><span style="background-color:#00ff00;">Go to their website and download    the version of mod_ssl that matches your version of apache. Put    the file into /usr/local/src. In this example I have used the file :</span></p>
<blockquote>
<pre><span style="background-color:#00ff00;">mod_ssl-2.8.14-1.3.27.tar.gz</span></pre>
</blockquote>
<p><span style="background-color:#00ff00;">Extract the source </span>:</p>
<blockquote>
<pre><span style="background-color:#00ff00;">cd /usr/local/src
tar xzf mod_ssl-2.8.14-1.3.27.tar.gz
chown -R root.root mod_ssl-2.8.14-1.3.27.tar.gz
cd mod_ssl-2.8.14-1.3.27</span></pre>
</blockquote>
<p><span style="background-color:#00ff00;">And now use the configure script to    patch the apache source tree</span></p>
<blockquote>
<pre><span style="background-color:#00ff00;">./configure \
  --with-apache=../apache_1.3.27 \
  --with-crt=/usr/local/ssl/certs/webmail.<font color="#ff0066">yourdomain.com</font>.crt \
  --with-key=/usr/local/ssl/private/webmail.<font color="#ff0066">yourdomain.com</font>.key</span></pre>
</blockquote>
</blockquote>
<p>Compile the apache source</p>
<blockquote>
<pre>cd /usr/local/src
cd apache_1.3.27
<span style="background-color:#00ff00;">SSL_BASE=../openssl-0.9.7b \
</span>./configure \
  --prefix=/usr/local/apache \
  --enable-module=so \
  --enable-module=rewrite \
  --enable-shared=rewrite \
<span style="background-color:#00ff00;">  --enable-module=ssl \
  --enable-shared=ssl \
  --disable-rule=SSL_COMPAT \
</span>  --server-uid=www \
  --server-gid=www</pre>
<pre>make
make install</pre>
</blockquote>
<p>Now add  PHP scripting support</p>
<blockquote><p><a href="http://www.php.net/">www.php.net</a></p>
<p>Go to their website and download the latest source to /usr/local/src. In    this example I have used :</p>
<blockquote>
<pre>php-4.3.11.tar.gz</pre>
</blockquote>
<p>Extract the source</p>
<blockquote>
<pre>cd /usr/local/src
tar xzf php-4.3.11.tar.gz
chown -R root.root php-4.3.11
cd php-4.3.11</pre>
</blockquote>
<p>And now use the configure script to patch the Apache source tree</p>
<blockquote>
<pre>./configure \
  --with-mysql=/usr/local/mysql \
  --with-apxs=/usr/local/apache/bin/apxs
make
make install</pre>
</blockquote>
<p align="left">Put the sample php.ini file into the required location</p>
<blockquote>
<p align="left">
<pre>cp php.ini-dist /usr/local/lib/php.ini</pre>
</blockquote>
<p align="left">Modify the /usr/local/lib/php.ini file and make sure it    contains the following commands</p>
<blockquote>
<p align="left">
<pre>max_execution_time=60
memory_limit=10M
post_max_size=8M
upload_max_filesize=8M
file_uploads=On
log_errors=On
error_log=/usr/local/apache/logs/php_error_log</pre>
</blockquote>
</blockquote>
<p align="left">
<blockquote><p>Tighten the security on PHP dir</p>
<blockquote>
<pre># Since we have installed PHP as a module, it will run in our chosen "www" context.
# We will now tighten up the permissions on the php directory to allow only root and www users access
chown -R root.www /usr/local/lib/php
chmod -R g-w,o-rwx /usr/local/lib/php</pre>
</blockquote>
</blockquote>
<p>Edit the /usr/local/apache/conf/httpd.conf file</p>
<blockquote>
<pre>User www
Group www</pre>
<pre>ServerAdmin postmaster@<font color="#ff0066">yourdomain.com</font>
ServerName  webmail.<font color="#ff0066">yourdomain.com</font></pre>
<pre># Following line should be present already as it would be inserted by the PHP make
# Make sure you move it outside of the IfDefineSSL section if the make (incorrectly) put it there
LoadModule php4_module libexec/libphp4.so</pre>
<pre># uncomment (or add) the following line
AddType application/x-httpd-php .php</pre>
<pre># Add the index.php into this line so apache will use this file as a default in addition to index.html
DirectoryIndex index.php index.html</pre>
<pre><span style="background-color:#00ff00;"># Go towards the end of the httpd.conf and look for the "SSL Virtual Host Context"
ServerName webmail.<font color="#ff0066">yourdomain.com</font>
ServerAdmin postmaster@</span><font color="#ff0066"><span style="background-color:#00ff00;">yourdomain.com</span></font></pre>
</blockquote>
<p align="left">Tidy up the default Apache contents dir</p>
<blockquote>
<p align="left">
<pre>rm -Rf /usr/local/apache/htdocs/*
rm -f /usr/local/apache/index.html.*</pre>
</blockquote>
<p align="left">
<p align="left">Tidy up the default Apache cgi-bin dir</p>
<blockquote>
<p align="left">
<pre>rm -Rf /usr/local/apache/cgi-bin/*</pre>
</blockquote>
<p align="left">Setup permissions on the Apache dirs</p>
<blockquote>
<pre>cd /usr/local

# make root.root own the entire Apache tree
chown -R root.root apache

# setup permissions on the apachedir.
# Because it is owned by root.root, we need to make sure the world permissions bits
# allow rx so that the www group in particular can get access to the apacheroot
chmod 755 apache

# now set the rest of the apacheroot to only allow root to rw. Everything else blocked
# we will selectively go and open permissions as needed
chmod -R 600 apache/*

# give owner (root) search/access permissions on all directories in the apacheroot
chmod -R u+X apache

cd apache

# bin dir contains binaries, so grant execute permissions to owner (root)
chmod -R u+x bin

# cgi-bin contains binaries. Allow either owner (root), or group (web server (www)) to execute these
chgrp -R www cgi-bin
chmod -R u+x,g+x cgi-bin

# the web server needs read access the icons dir
chgrp -R www icons
chmod -R g+rX icons

# Web server log files can be written by the service processes
# but the log files cannot be read or served as web content.
# Web server log files can be read only by administration processes
chgrp -R www logs
chmod g+wX logs

# public web files needs to be able to be read, but not written to by the web service processes
# Also the directories where public web content is stored must not be writable by web services processes
# Also public web content files can be written only by processes authorised for web server admin (only root in our case)
chgrp -R www htdocs
chmod -R g+rX htdocs</pre>
</blockquote>
<p align="left"><strong>OPTIONAL : ADD MOD_GZIP SUPPORT</strong></p>
<blockquote>
<p align="left"><a href="http://sourceforge.net/projects/mod-gzip/">   http://sourceforge.net/projects/mod-gzip/</a></p>
<p align="left">mod_gzip is a module for Apache that allows you to compress    outgoing content from an Apache web server on-the-fly. It uses the same    compression as gzip and no plugins or extra software is needed by your browser    to take advantage of this product. Reduction in size of up to 90% or more is    possible.</p>
<p align="left">Go to their website and download the latest source to /usr/local/src.    In this example I have used :</p>
<blockquote>
<p align="left">
<pre>mod_gzip-1.3.26.1a.tar</pre>
</blockquote>
<p align="left">Unpack the sources</p>
<blockquote>
<p align="left">
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/mod-gzip/mod_gzip-1.3.26.1a.tgz">http://optusnet.dl.sourceforge.net/sourceforge/mod-gzip/mod_gzip-1.3.26.1a.tgz</a>
tar xzf mod_gzip-1.3.26.1a.tgz
chown -R root.root mod_gzip-1.3.26.1a
cd mod_gzip-1.3.26.1a</pre>
</blockquote>
<p align="left">
<p align="left">Compile</p>
<blockquote>
<p align="left">
<pre>APXS=/usr/local/apache/bin/apxs make
APXS=/usr/local/apache/bin/apxs make install</pre>
</blockquote>
<p align="left">
<p align="left">Setup the mod_gzip config in the Apache&#8217;s httpd.conf file</p>
<p align="left">
<blockquote>
<pre>vi /usr/local/apache/conf/httpd.conf</pre>
<blockquote>
<pre># Add the following commands to the httpd.conf file.
# ( Insert them before all the SSL config options )

LoadModule gzip_module libexec/mod_gzip.so
&lt;IfModule mod_gzip.c&gt;</pre>
<blockquote>
<pre>mod_gzip_on Yes
mod_gzip_temp_dir /tmp
mod_gzip_keep_workfiles No
mod_gzip_minimum_file_size 500
mod_gzip_maximum_file_size 5000000
mod_gzip_maximum_inmem_size 60000
mod_gzip_handle_methods GET</pre>
<pre>mod_gzip_item_include file "\.htm$"
mod_gzip_item_include file "\.html$"
mod_gzip_item_include file "\.txt$"
mod_gzip_item_include file "\.php$"

mod_gzip_item_include mime "text/*"
mod_gzip_item_include mime "httpd/unix-directory"
mod_gzip_item_include mime "application/x-httpd-php"

mod_gzip_item_exclude file "\.css$"
mod_gzip_item_exclude file "\.js$"
mod_gzip_item_exclude file "\.wml$"

mod_gzip_dechunk Yes

LogFormat "%h %l %u %t \"%r\" %&gt;s %b mod_gzip: %{mod_gzip_compression_ratio}npct." common_with_mod_gzip_info1
# CustomLog /usr/local/apache/logs/mod_gzip common_with_mod_gzip_info1</pre>
<pre>LogFormat "%h %l %u %t \"%V %r\" %&gt;s %b mod_gzip: %{mod_gzip_result}n In:%{mod_gzip_input_size}n Out:%{mod_gzip_output_size}n:%{mod_gzip_compression_ratio}npct." common_with_mod_gzip_info2
CustomLog /usr/local/apache/logs/mod_gzip common_with_mod_gzip_info2</pre>
<pre>mod_gzip_add_header_count Yes</pre>
</blockquote>
<pre>&lt;/IfModule&gt;</pre>
<pre># and then put this command inside the &lt;VirtualHost _default_:443&gt; section
# since it isnt possible to successfully gzip SSL pages</pre>
<blockquote>
<pre>mod_gzip_on No</pre>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<p align="left"><strong>CRANK IT UP!</strong></p>
<blockquote>
<p align="left">
<p align="left">Test your httpd.conf for valid syntax</p>
<blockquote>
<p align="left">
<pre>/usr/local/apache/bin/apachectl configtest</pre>
</blockquote>
<p align="left">Try starting the Apache server</p>
<blockquote><p><span style="background-color:#00ff00;"># if you are using SSL :</span></p>
<p align="left">
<blockquote>
<pre><span style="background-color:#00ff00;">/usr/local/apache/bin/apachectl startssl</span></pre>
</blockquote>
<p align="left">
<pre># if you aren't using SSL</pre>
<p align="left">
<blockquote>
<pre>/usr/local/apache/bin/apachectl start</pre>
</blockquote>
</blockquote>
<p>At this point the apache daemon should be running. A good way to verify    this is to use this command :</p>
<blockquote>
<pre>ps axf</pre>
</blockquote>
<p>If all is well, you should be able to see something like this :</p>
<p align="left">
<blockquote>
<p align="left">
<pre>1210 ? S 0:00 /usr/local/apache/bin/httpd <span style="background-color:#00ff00;">-DSSL</span>
1274 ? S 0:03  \_ /usr/local/apache/bin/httpd <span style="background-color:#00ff00;">-DSSL</span>
1275 ? S 0:00  \_ /usr/local/apache/bin/httpd <span style="background-color:#00ff00;">-DSSL</span>
1276 ? S 0:02  \_ /usr/local/apache/bin/httpd <span style="background-color:#00ff00;">-DSSL</span>
1277 ? S 0:03  \_ /usr/local/apache/bin/httpd <span style="background-color:#00ff00;">-DSSL</span>
1278 ? S 0:01  \_ /usr/local/apache/bin/httpd <span style="background-color:#00ff00;">-DSSL</span></pre>
</blockquote>
<p align="left"> If that all    looks good, then now we need to configure a startup script for apache, so it    launches every time at bootup</p>
<blockquote>
<p align="left">
<pre>vi /etc/rc.d/init.d/httpd</pre>
<p align="left">
<blockquote>
<pre>#!/bin/sh
#
# Startup script for the Apache Web Server
#
# chkconfig: 345 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
  start)
	echo -n "Starting httpd: "
	daemon /usr/local/apache/bin/httpd<span style="background-color:#00ff00;"> -DSSL</span>
	echo
	touch /var/lock/subsys/httpd
  ;;
  stop)
	echo -n "Shutting down http: "
	killproc httpd
	echo
	rm -f /var/lock/subsys/httpd
	rm -f /var/run/httpd.pid
  ;;
  status)
	status httpd
  ;;
  restart)
	$0 stop
	$0 start
  ;;
  reload)
	echo -n "Reloading httpd: "
	killproc httpd -HUP
	echo
  ;;
  *)
	echo "Usage: $0 {start|stop|restart|reload|status}"
	exit 1
esac

exit 0</pre>
</blockquote>
</blockquote>
<p align="left">Setup permissions etc for the startup script</p>
<p align="left">
<blockquote>
<pre>chown root.root /etc/rc.d/init.d/httpd
chmod 744 /etc/rc.d/init.d/httpd</pre>
<pre>chkconfig --add httpd</pre>
<p>Then I like to use the <font face="Courier" size="2">ntsysv</font> program    to double-check that httpd is set to launch at boot time</p></blockquote>
</blockquote>
<hr />
<h3 align="left"><a name="QMAIL"></a>QMAIL</h3>
<p align="left">I recommend that you follow the instruction guide at <a href="http://www.lifewithqmail.org/">www.lifewithqmail.org</a></p>
<p align="left">&nbsp;</p>
<p align="left">However, if you really want to see how we normally do it, here  are the steps :</p>
<p><strong>INSTALL UCSPI-TCP</strong></p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz">http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz</a>
wget <a href="http://www.qmail.org/ucspi-rss.diff">http://www.qmail.org/ucspi-rss.diff</a>
tar xzf ucspi-tcp-0.88.tar.gz
chown -R root.root ucspi-tcp-0.88
cd ucspi-tcp-0.88</pre>
<pre># Patch rblsmtpd so that it can be used with all the newer RBL zones.
# This patch also lets you specify a custom error message to be returned to the sender.
patch -p0 rblsmtpd.c &lt; ../ucspi-rss.diff</pre>
<pre># Modify rblsmtpd.c to increase the maximum size of the error text that is allowed
# to be returned to the sender from 200 to 500 chars.
# This allows you to create some nice and descriptive text to send to people who
# are being blocked by your RBL filters
vi rblsmtpd.c</pre>
<blockquote><p>go to line 166 and change it from</p>
<pre>if (text.len &gt; 200) text.len = 200;</pre>
<p>to</p>
<pre>if (text.len &gt; 500) text.len = 500;</pre>
</blockquote>
<pre>make
make setup check</pre>
</blockquote>
<p><strong>INSTALL DAEMONTOOLS</strong></p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://cr.yp.to/daemontools/daemontools-0.76.tar.gz">http://cr.yp.to/daemontools/daemontools-0.76.tar.gz</a></pre>
<pre>mkdir -p /package
chmod 1755 /package
cd /package</pre>
<pre>tar xzfp /usr/local/src/daemontools-0.76.tar.gz
cd admin/daemontools-0.76</pre>
<pre>package/install</pre>
</blockquote>
<p><strong>INSTALL QMAIL</strong></p>
<blockquote><p>Download the required files</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://cr.yp.to/software/qmail-1.03.tar.gz">http://cr.yp.to/software/qmail-1.03.tar.gz</a>
wget <a href="http://www.ckdhr.com/ckd/qmail-103.patch">http://www.ckdhr.com/ckd/qmail-103.patch</a>
wget <a href="http://www.qmail.org/qmailqueue-patch">http://www.qmail.org/qmailqueue-patch</a>
wget <a href="http://www.shupp.org/patches/qmail-maildir++.patch">http://www.shupp.org/patches/qmail-maildir++.patch</a>
wget <a href="http://www.bowe.id.au/michael/Sources/Linux/WebMail/qmail-date-localtime.patch.txt">http://www.bowe.id.au/michael/Sources/Linux/WebMail/qmail-date-localtime.patch.txt</a>
wget <a href="http://www.bowe.id.au/michael/sources/linux/WebMail/qmail-limit-bounce-size.patch.txt">http://www.bowe.id.au/michael/sources/linux/WebMail/qmail-limit-bounce-size.patch.txt</a>
wget <a href="http://www.bowe.id.au/michael/Sources/Linux/WebMail/qregex.patch-20020129.txt">http://www.bowe.id.au/michael/Sources/Linux/WebMail/qregex.patch-20020129.txt</a>
wget <a href="http://www.bowe.id.au/michael/Sources/Linux/WebMail/qmail-smtpd-esmtp-size_qregex-compat.diff.txt">http://www.bowe.id.au/michael/Sources/Linux/WebMail/qmail-smtpd-esmtp-size_qregex-compat.diff.txt</a></pre>
<pre>wget <a href="http://www.bowe.id.au/michael/sources/linux/WebMail/qmailctl.txt">http://www.bowe.id.au/michael/sources/linux/WebMail/qmailctl.txt</a></pre>
</blockquote>
<p>Create the users and groups required for qmail</p>
<blockquote>
<pre>groupadd nofiles
useradd -g nofiles -d /var/qmail qmaild
useradd -g nofiles -d /var/qmail qmaill
useradd -g nofiles -d /var/qmail qmailp
useradd -g nofiles -d /var/qmail/alias alias
groupadd qmail
useradd -g qmail -d /var/qmail qmailq
useradd -g qmail -d /var/qmail qmailr
useradd -g qmail -d /var/qmail qmails</pre>
</blockquote>
<p>Unzip the sources, apply the required patches, compile</p>
<blockquote>
<pre>tar xzf qmail-1.03.tar.gz
cd qmail-1.03</pre>
<pre># <span>A</span>pply <span>patch that allows qmail to work with </span>oversize <span>DNS</span> <span>packets</span>
patch -p1 &lt; ../qmail-103.patch</pre>
<pre># <span>A</span>pply the "qmailqueue" patch
# <span>T</span>his patch gives you the required support for other popular addons like <a href="http://qmail-scanner.sourceforge.net/">Qmail-Scanner</a>
patch -p1 &lt; ../qmailqueue-patch</pre>
<pre># <span>A</span>pply patch to make qmail-local and qmail-pop3d compatible with the maildir++ quota
# system that is used by vpopmail and courier-imap
patch &lt; ../qmail-maildir++.patch</pre>
<pre># <span>A</span>pply patch for local timestamps.
# This will make the emails headers be written in localtime rather than GMT
patch -p1 &lt; ../qmail-date-localtime.patch.txt</pre>
<pre># <span>A</span>pply patch to limit the size of bounce messages generated by our server.
# <span>T</span>he patch will limit the size of the bounce to be 50K,
# or you can override this by setting a different value in /var/qmail/control/bouncemaxbytes
patch &lt; ../qmail-limit-bounce-size.patch.txt</pre>
<pre># Now add the <a href="http://www.unixpimps.org/software/qregex/">qregex</a> patch, which adds regexp support to qmail's badmailfrom,
# and also implements badmailto checking (again with regexp support)
patch &lt; ../qregex.patch-20020129.txt</pre>
<pre># <span>A</span>pply patch to add ESMTP SIZE support to qmail-smtpd
# This helps your server be able to reject excessively large messages "up front",
# rather than waiting for the whole message to arrive and then bouncing it because
# exceeded the <span>/var/qmail/control/</span>databytes setting.
# Nother that particular patch has been modified so it will apply cleanly in
# conjunction with the other patches I have supplied above. The original version
# of this patch would fail because it conflicted with the qregex patch.
patch &lt; ../qmail-smtpd-esmtp-size_qregex-compat.diff.txt</pre>
<p><span>E</span>dit qmail-smtpd.c and change the code on the straynewline function (around    line 54) from 451 to 553<br />
Without this you will get nasty loops forming when a remote servers sends you    an message with invalid formatting. By default qmail will says something like     &#8220;I am not going to accept that message at the moment, you can try again    later&#8221;. However in my experience the sending server will try sending the same    message again a few seconds later, and this will go around and around in a    loop for days on end &#8211; consuming valuable bandwidth and resources. By changing    the error code to 553, it is making the error be permanent ie &#8220;I am not going    to accept that message, don&#8217;t try sending it again&#8221;</p>
<pre>make setup check
./config
cd ..</pre>
</blockquote>
<p>Remove the sendmail package, and link in qmail&#8217;s replacement utility</p>
<blockquote>
<pre># If you are running redhat 8, you may first need to remove the postfix
# package, so that mail to someuser@<font color="#ff0066">hostname.yourdomain.com </font>will work correctly :
rpm -e --nodeps postfix</pre>
<pre># OK, now go ahead and remove the sendmail package
rpm -e --nodeps sendmail
# Link in qmail's replacement "sendmail-like" tools
ln -s /var/qmail/bin/sendmail /usr/lib
ln -s /var/qmail/bin/sendmail /usr/sbin</pre>
</blockquote>
<p>The qmailctl script contains all the various commands that will allow us to    control our qmail daemons. Put it in with the other qmail binaries. Also link    it into /usr/bin so it will be in our &#8220;path&#8221; for easy access</p>
<blockquote>
<pre>cp /usr/local/src/qmailctl.txt /var/qmail/bin/qmailctl
chmod 755 /var/qmail/bin/qmailctl</pre>
<pre>ln -s /var/qmail/bin/qmailctl /usr/bin</pre>
</blockquote>
<p>Setup the /etc/tcp.smtp file<br />
This file controls who is allowed to send and/or relay mail on this server<br />
An example configuration follows :</p>
<blockquote>
<pre>#------------------------------------------------------
# DESCRIPTION OF THE RULES TO REMIND ME OF HOW THIS FILE WORKS
#
# If you set 'allow', this means that our mail server will allow
# the specified IP range to make a TCP connection to our server
#
# If you set 'deny', this means that our mail server will not allow
# the specified IP range to make a TCP connection to our server
#
# If you set RELAYCLIENT="", this means that the listed IP range is
# allowed to relay mail through our server
#
# If you dont set RELAYCLIENT="", this means that the listed IP range
# will not be able to relay mail through our server
#
# If you set RBLSMTPD="", this means that the listed IP ranges will
# not be checked against any of the RBL databases
#
# If you set RBLSMTPD="some text here", this means that an RBL lookup
# wont be performed, but the mail will be rejected with the specified
# text as a 4xx temp error message
#
# If you set RBLSMTPD="-some text here", this means that an RBL lookup
# wont be performed, but the mail will be rejected with the specified
# text as a 5xx perm error message
#
# If you do not set RBLSMTPD="" or ="some text", then an RBL lookup
# will be performed. If the lookup is successful, then RBLSMTPD will
# return your custom error message (as specified in the -r parameter
# in smtpd supervise script)
#
#-----------------------------------------------------
# HERE ARE THE RULES! :
#-----------------------------------------------------
# BYPASS OPEN RELAY CHECKING FOR THESE IPS :
#
# These IPs are ones that we have setup so that they arent RBL checked.
# We have done this because these particular servers are RBL listed,
# and for whatever reason they can't/won't fix their open relay problem,
# and we still want to be able to receive mail from them.
#
# reminder text goes here for this entry so we know the story...
111.111.111.111:allow,RBLSMTPD=""
# reminder text goes here for this entry so we know the story...
222.222.222.222:allow,RBLSMTPD=""
#
#-----------------------------------------------------------------
# DONT ALLOW THESE IPS TO SEND MAIL TO US :
#
# mailXX.offermail.net connecting regularly and sending invalid
# format messages causing exit with status 256 (bare linefeed normally)
# entry added 15/12/2001
# after looking at the mail coming from these servers it was found to be spam
216.242.75.100-116:allow,RBLSMTPD="-Connections from this IP have been banned."
#
# heaps of spam from replyto of *@freeamateurhotties.com dec2001
64.228.127.:allow,RBLSMTPD="-Connections refused due to spam from freeamateurhotties.com"
154.20.94.:allow,RBLSMTPD="-Connections refused due to spam from freeamateurhotties.com"
209.151.132.:allow,RBLSMTPD="-Connections refused due to spam from freeamateurhotties.com"
216.18.85.:allow,RBLSMTPD="-Connections refused due to spam from freeamateurhotties.com"
#
#-----------------------------------------------------------------
# ALLOW THESE IPS TO RELAY MAIL THROUGH OUR SERVER
#
# Local class-c's from our LAN are allowed to relay,
# and we wont bother doing any RBL checking.
123.123.123.:allow,RELAYCLIENT="",RBLSMTPD=""
123.111.111.:allow,RELAYCLIENT="",RBLSMTPD=""
#
# Connections from localhost are allowed to relay
# (because the WebMail server runs on localhost),
# and obviously there is no point trying to perform an RBL check.
127.0.0.1:allow,RELAYCLIENT="",RBLSMTPD=""
#
#-----------------------------------------------------------------
# ALLOW EVERYONE ELSE TO SEND US MAIL
#
# Everyone else can make connections to our server,
# but not allowed to relay
# RBL lookups are performed
:allow</pre>
</blockquote>
<p>Setup the /etc/tcp.pop3  file<br />
This file controls who is allowed to access the POP3 services on this server<br />
An example configuration follows :</p>
<blockquote>
<pre># Allow any client to connect to us via POP3
# If people are abusing POP3 such as denial-of-service on POP3,
# you can add their ips here to block them out
:allow</pre>
</blockquote>
<p>Now we have created our tcp.smtp and tcp.pop3 files, we need to compile    them into the cdb database format that the tcpserver program can read</p>
<blockquote>
<pre>qmailctl cdb</pre>
</blockquote>
<p>Adjust various aspects of the qmail configuration to suite our tastes :</p>
<blockquote>
<pre># use postmaster@<font color="#ff0066">hostname.yourdomain.com </font>as sender in bounce messages
# rather than the default MAILER-DAEMON@<font color="#ff0066">hostname.yourdomain.com
</font>echo 'postmaster' &gt; /var/qmail/control/bouncefrom</pre>
<pre># Define how to handle "double bounces".
# The server admin has two choices here, either to receive double bounces
# or to discard them. If your server doesn't handle a lot of mail then it
# wouldn't hurt to receive all double bounces for the admin's inspection.
# But if your server handles a lot of mail, then it is more likely that you
# are going to want to discard double-bounces, because you will end up with
# potentially thousands of these every day.
#
# If you want to keep double-bounces, use these commands to nominate what
# email address to send them through to (eg doublebounce@<font color="#ff0066">yourdomain.com) </font>:
echo 'doublebounce' &gt; /var/qmail/control/doublebounceto
echo '<font color="#ff0066">yourdomain.com</font>' &gt; /var/qmail/control/doublebouncehost
# (dont forget that you will need to make sure you have created a mailbox
# to receive these mails. You could use qmailadmin to create a dedicated
# mailbox, or perhaps setup an alias on an existing mailbox)
#
# Or if you would prefer to silently discard any doublebounces,
# then use these commands instead
echo 'doublebounce' &gt; /var/qmail/control/doublebounceto
echo '<font color="#ff0066">hostname.yourdomain.com</font>' &gt; /var/qmail/control/doublebouncehost
echo '#' &gt; ~alias/.qmail-doublebounce
chmod 644 ~alias/.qmail-doublebounce</pre>
<pre># set maximum message size to be 8Mb
echo '8000000' &gt; /var/qmail/control/databytes</pre>
<pre># queue mail for up to 4 days
echo '345600' &gt; /var/qmail/control/queuelifetime</pre>
<pre># Populate badmailto so that mail with invalid address formatting gets rejected
echo '# reject containing invalid characters, brackets or multiple @' &gt; /var/qmail/control/badmailto
echo '[!%#:\*\^]' &gt;&gt; /var/qmail/control/badmailto
echo '[\(\)]'         &gt;&gt; /var/qmail/control/badmailto
echo '[\{\}]'         &gt;&gt; /var/qmail/control/badmailto
echo '@.*@'           &gt;&gt; /var/qmail/control/badmailto</pre>
<pre># setup the default domain for use where an address does not have a domain specified
echo '<font color="#ff0066">yourdomain.com</font>' &gt; /var/qmail/control/defaultdomain</pre>
<pre># Note, this following command is optional!
#
# If you want qmail to send all outbound mail via a particular mail server
# rather than to send it direct to the recipient's mail server, then this
# can be achieved with the smtproutes command.
#
# SEND ALL OUTBOUND MAIL VIA SMARTHOST
echo ':<font color="#ff0066">yoursmarthost.yourdomain.com</font>' &gt; /var/qmail/control/smtproutes</pre>
<pre># redirect any mail sent to root@<font color="#ff0066"><strong>hostname</strong>.yourdomain.com </font>to 'postmaster@<font color="#ff0066">yourdomain.com</font>
# redirect any mail sent to postmaster@<font color="#ff0066"><strong>hostname</strong>.yourdomain.com </font>to 'postmaster@<font color="#ff0066">yourdomain.com</font>
# redirect any mail sent to mailer-daemon@<font color="#ff0066"><strong>hostname</strong>.yourdomain.com </font>to 'postmaster@<font color="#ff0066">yourdomain.com</font>
echo 'postmaster@<font color="#ff0066">yourdomain.com</font>' &gt; ~alias/.qmail-root
echo 'postmaster@<font color="#ff0066">yourdomain.com</font>' &gt; ~alias/.qmail-postmaster
echo 'postmaster@<font color="#ff0066">yourdomain.com</font>' &gt; ~alias/.qmail-mailer-daemon
chmod 644 ~alias/.qmail-*</pre>
</blockquote>
<p>Create / configure the various qmail run scripts :</p>
<blockquote>
<pre>cd /etc/rc.d/init.d
ln -s /var/qmail/bin/qmailctl /etc/rc.d/init.d/qmail
ln -s ../init.d/qmail /etc/rc.d/rc0.d/K30qmail
ln -s ../init.d/qmail /etc/rc.d/rc1.d/K30qmail
ln -s ../init.d/qmail /etc/rc.d/rc2.d/S80qmail
ln -s ../init.d/qmail /etc/rc.d/rc3.d/S80qmail
ln -s ../init.d/qmail /etc/rc.d/rc4.d/S80qmail
ln -s ../init.d/qmail /etc/rc.d/rc5.d/S80qmail
ln -s ../init.d/qmail /etc/rc.d/rc6.d/K30qmail</pre>
<pre>mkdir -p /var/qmail/supervise/qmail-send/log
mkdir -p /var/qmail/supervise/qmail-smtpd/log
mkdir -p /var/qmail/supervise/qmail-pop3d/log
chmod +t /var/qmail/supervise/qmail-send
chmod +t /var/qmail/supervise/qmail-smtpd
chmod +t /var/qmail/supervise/qmail-pop3d</pre>
<pre>vi /var/qmail/supervise/qmail-send/run</pre>
<blockquote>
<pre>#!/bin/sh
exec env - PATH="/var/qmail/bin:$PATH" qmail-start ./Maildir/</pre>
</blockquote>
<pre>vi /var/qmail/supervise/qmail-send/log/run</pre>
<blockquote>
<pre>#!/bin/sh
# Keep 30 logs of max 10Mb each
#
# They will get rotated when they reach 10Mb in size,
# or at midnight when our crontab script fires (whichever event comes 1st)
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/send</pre>
</blockquote>
<pre>vi /var/qmail/supervise/qmail-smtpd/run</pre>
<blockquote>
<pre>#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`

exec /usr/local/bin/softlimit -m 4000000 \
/usr/local/bin/tcpserver \
<span style="background-color:#ffcc66;">  -H -l </span><font color="#ff0066"><span style="background-color:#ffcc66;">hostname.yourdomain.com</span></font><span style="background-color:#ffcc66;"> \
</span>  -v -x /etc/tcp.smtp.cdb \
  -c 20 -R -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/usr/local/bin/rblsmtpd -b -C \
  -r 'list.dsbl.org:Your message was rejected because the message was sent from a server listed in DSBL - More information regarding this problem is available at http://dsbl.org/listing?%IP% - Please forward this error to your email server support staff for resolution.' \
  -r 'sbl-xbl.spamhaus.org:Your message was rejected because the message was sent from a server listed in the Spamhaus RBL - More information regarding this problems is available at http://www.spamhaus.org/query/bl?ip=%IP% - Please forward this error to your email server support staff for resolution.' \
  -t 5 \
/var/qmail/bin/qmail-smtpd 2&gt;&amp;1</pre>
<pre># The line in orange should be used if you are running qmail on a computer
# that is on a LAN that is using fake ips/masquerading.
# It tells tcpserver not to bother trying to resolve ip addresses
# to names when writing the SMTP log files. Usually with fake ips,
# you cant resolve them to names, so it will make the SMTP services run
# really slowly if it is always trying to resolve these addresses.
# Alternatively, if you are eg an ISP and all your SMTP clients are
# connecting from real IPs with resolvable names, then you can omit
# the orange line and then then benefit from more readable logfiles.</pre>
</blockquote>
<pre>vi /var/qmail/supervise/qmail-smtpd/log/run</pre>
<blockquote>
<pre>#!/bin/sh
# Keep 30 logs of max 10Mb each
#
# They will get rotated when they reach 10Mb in size,
# or at midnight when our crontab script fires (whichever event comes 1st)
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/smtpd</pre>
</blockquote>
<pre>vi /var/qmail/supervise/qmail-pop3d/run</pre>
<blockquote>
<pre>#!/bin/sh
exec /usr/local/bin/softlimit -m 6000000 \
/usr/local/bin/tcpserver \
<span style="background-color:#ffcc66;">  -H -l </span><font color="#ff0066"><span style="background-color:#ffcc66;">hostname.yourdomain.com</span></font><span style="background-color:#ffcc66;"> \
</span>  -v -x /etc/tcp.pop3.cdb -c 30 -R 0 pop3 \
/var/qmail/bin/qmail-popup <font color="#ff0066">hostname.yourdomain.com</font> \
/home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2&gt;&amp;1</pre>
<pre># The line in orange should be used if you are running qmail on a computer
# that is on a LAN that is using fake ips/masquerading.
# It tells tcpserver not to bother trying to resolve ip addresses
# to names when writing the POP3 log files. Usually with fake ips,
# you cant resolve them to names, so it will make the POP3 services run
# really slowly if it is always trying to resolve these addresses.
# Alternatively, if you are eg an ISP and all your POP3 clients are
# connecting from real IPs with resolvable names, then you can omit
# the orange line and then then benefit from more readable logfiles.</pre>
</blockquote>
<pre>vi /var/qmail/supervise/qmail-pop3d/log/run</pre>
<blockquote>
<pre>#!/bin/sh
# Keep 30 logs of max 10Mb each
# They will get rotated when they reach 10Mb in size,
# or at midnight when our crontab script fires (whichever event comes 1st)
exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/pop3d</pre>
</blockquote>
<pre>chmod 755 /var/qmail/supervise/qmail-send/run
chmod 755 /var/qmail/supervise/qmail-send/log/run
chmod 755 /var/qmail/supervise/qmail-smtpd/run
chmod 755 /var/qmail/supervise/qmail-smtpd/log/run
chmod 755 /var/qmail/supervise/qmail-pop3d/run
chmod 755 /var/qmail/supervise/qmail-pop3d/log/run</pre>
<pre>mkdir /var/log/qmail
mkdir /var/log/qmail/smtpd
mkdir /var/log/qmail/send
mkdir /var/log/qmail/pop3d</pre>
<pre>chown -R qmaill /var/log/qmail</pre>
<pre>crontab -e</pre>
<blockquote>
<pre># the following 3 lines rotate the qmail log files daily
0 0 * * * /usr/local/bin/svc -a /service/qmail-smtpd/log
0 0 * * * /usr/local/bin/svc -a /service/qmail-send/log
0 0 * * * /usr/local/bin/svc -a /service/qmail-pop3d/log</pre>
</blockquote>
<pre>ln -s /var/qmail/supervise/qmail-send /service
ln -s /var/qmail/supervise/qmail-smtpd /service
ln -s /var/qmail/supervise/qmail-pop3d /service</pre>
</blockquote>
<p>At this point the qmail daemons should be running. A good way to verify    this is to use this command :</p>
<blockquote>
<pre>ps axf</pre>
</blockquote>
<p>If all is well, you should be able to see something like this :</p>
<blockquote>
<pre>1218 ? S 0:00 /bin/sh /command/svscanboot
1222 ? S 0:00  \_ svscan /service
1224 ? S 0:00  |   \_ supervise <strong>qmail-send</strong>
1230 ? S 0:00  |   |   \_ qmail-send
1236 ? S 0:00  |   |   \_ qmail-lspawn ./Maildir/
1237 ? S 0:00  |   |   \_ qmail-rspawn
1238 ? S 0:00  |   |   \_ qmail-clean
1225 ? S 0:00  |   \_ supervise log
1233 ? S 0:00  |   |   \_ /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/send
1226 ? S 0:00  |   \_ supervise <strong>qmail-smtpd</strong>
1231 ? S 0:00  |   |   \_ /usr/local/bin/tcpserver -v -x /etc/tcp.smtp.cdb -c 20 -R -u 504 -g 503 0 smtp /var/qmail/bin
1227 ? S 0:00  |   \_ supervise log
1234 ? S 0:00  |   |   \_ /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/smtpd
1228 ? S 0:00  |   \_ supervise <strong>qmail-pop3d</strong>
1232 ? S 0:00  |   |   \_ /usr/local/bin/tcpserver -v -x /etc/tcp.pop3.cdb -c 30 -H -R 0 110 /var/qmail/bin/qmail-popup
1229 ? S 0:00  |   \_ supervise log
1235 ? S 0:00  |       \_ /usr/local/bin/multilog t s10000000 n30 /var/log/qmail/pop3d
1223 ? S 0:00  \_ readproctitle service errors: .......................................................................</pre>
</blockquote>
<p>Note the 3 qmail daemons <strong>: qmail-send</strong>, <strong>qmail-smtpd</strong>, <strong>   qmail-pop3d</strong>, as well as their associated logging processes. If there is    anything wrong with your install, an error message will generally be visible    on the &#8220;readproctitle&#8221; line</p>
<p>You can control the qmail daemons by using the   <font face="Courier New" size="2">qmailctl</font> program. You can just type    that command without any parameters and it will display the available options    eg start, stop, status, doqueue</p></blockquote>
<hr />
<h3><a name="VPOPMAIL"></a>VPOPMAIL</h3>
<p><a href="https://sourceforge.net/projects/vpopmail"> https://sourceforge.net/projects/vpopmail</a></p>
<p>Make the user accounts</p>
<blockquote>
<pre># If you are using RH8.0, you will probably need to run this following command,
# because RH8.0 comes preconfigured with UID/GID 89 allocated to postfix
#
# userdel postfix</pre>
<pre>groupadd -g 89 vchkpw
useradd -g vchkpw -u 89 -d /home/vpopmail vpopmail</pre>
<pre># We recommend you use the user and group id's of 89. The FreeBSD folks
# have reserved 89 for the group and 89 for the user for vpopmail. Feel
# free to have the OS assign the group/user id (for example, Solaris won't
# allow gid 89).</pre>
</blockquote>
<p>Download and unpack the source</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/vpopmail/vpopmail-5.4.10.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/vpopmail/vpopmail-5.4.10.tar.gz</a>
tar xzf vpopmail-5.4.10.tar.gz
chown -R root.root vpopmail-5.4.10
cd vpopmail-5.4.10</pre>
</blockquote>
<p>Setup the MySQL support in the vpopmail sources</p>
<blockquote>
<pre># Create the configuration file that vpopmail will use
# to setup the connection to the mysql database
#
# This example will tell vpopmail :
#   * Log into the server running on localhost
#   * Use the default mysql port
#       (In fact if the server is localhost, and you don't specify a port number, then
#        I believe the that communications are done via unix sockets rather than TCP/IP)
#   * Login with username <em>vpopmailuser</em>
#   * Login with password <em>vpoppasswd</em>
#   * Use the database called vpopmail
#</pre>
<pre>mkdir ~vpopmail/etc
chown vpopmail.vchkpw ~vpopmail/etc
echo "localhost|0|<em>vpopmailuser</em>|<em>vpoppasswd</em>|vpopmail" &gt; ~vpopmail/etc/vpopmail.mysql
chown vpopmail.vchkpw ~vpopmail/etc/vpopmail.mysql
chmod 640 ~vpopmail/etc/vpopmail.mysql</pre>
<pre># log into MySQL as the MySQL root user
# and then create the database for vpopmail to use
# and then setup the appropriate permissions on this database</pre>
<pre>/usr/local/mysql/bin/mysql --password="<em>mysql-root-pwd</em>"</pre>
<blockquote>
<pre>CREATE DATABASE vpopmail;</pre>
<pre>GRANT select,insert,update,delete,create,drop ON vpopmail.*
TO <em>vpopmailuser</em>@localhost IDENTIFIED BY '<em>vpoppasswd</em>';</pre>
<pre>quit</pre>
</blockquote>
</blockquote>
<p>Now, build the program</p>
<blockquote>
<table style="border-collapse:collapse;" border="1" cellpadding="5" width="900">
<tr>
<td valign="top" width="465">
<pre>./configure \
  --disable-roaming-users \<span style="background-color:#c0c0c0;">
</span>  --enable-logging=p \
  --disable-passwd \
  --enable-clear-passwd \
  --disable-domain-quotas \
  --enable-auth-module=mysql \
  --enable-auth-logging \
  --enable-sql-logging \
\
  --enable-valias \
  --disable-mysql-limits</pre>
</td>
<td valign="top" width="432">
<pre>
&lt;-- We aren't building roaming user support in this example<span style="background-color:#c0c0c0;">
</span>&lt;-- Log POP3 authentication errors including the failed password (to syslog)
&lt;-- Don't include /etc/passwd support. Our box doesn't have any "real" users, only vpopmail users
&lt;-- Enable storing passwords in clear-text. Makes your support staff's life much easier!
&lt;-- Domain quotas allow you to limit the amount of storage a particular domain can use. This code is buggy though and is not recommended for use.
&lt;-- Store all the user and domain information in MySQL rather than using disk-based "cdb" files
&lt;-- Maintain a lastauth table in MySQL (shows when / how a user last accessed their email)
&lt;-- Maintain the vlog table in MySQL (shows failed authentication requests).
    The verbosity of the logging will mirror what was chosen in the --enable-logging parameter.
&lt;-- Store aliases and autoresponder settings in MySQL rather than .qmail-xxxx files on the disk.
&lt;-- Use disk-based ".qmailadmin-limits" files rather than storing this data in MySQL.</pre>
</td>
</tr>
</table>
<pre>make
make install-strip</pre>
</blockquote>
<p>Notes :</p>
<blockquote><p>The   &#8220;&#8211;enable-mysql-limits&#8221; configuration option    is  fairly new. I plan to update my guide to use this function at some point    in the near future once I have done some testing etc of this functionality</p>
<p>I used to recommend the &#8211;disable-many-domains switch &#8211; which tells vpopmail to create one MySQL table per email domain. When I first started building vpopmail servers, I found this to be the most logical way, having each domain in its own table. However there has been some discussion about this config option on the vpopmail mailing lists, and it sound like this option may be removed at some point in the future.  If you have a lot of domains on your server, having each domain in its own table can hurt performance. I now agree that &#8211;enable-many-domains (which is the default) is probably the better choice</p></blockquote>
<p>Review the contents of the file is used to set the default limits for any domains /  mailboxes in the vpopmail system. Make sure it contains reasonable defaults for  your system.</p>
<blockquote>
<pre>vi ~vpopmail/etc/vlimits.default</pre>
<blockquote>
<pre># in particular set the default mailbox size to be something reasonable eg 20Mb
default_quota 20971520</pre>
</blockquote>
</blockquote>
<p>Optionally, nominate a &#8220;default domain&#8221;. Users in this domain can login to  POP3 etc using just their username. Users from all other domains need to use  their full email address as their login name.</p>
<blockquote>
<pre>echo "<font color="#ff0066">yourdomain.com</font>" &gt; /home/vpopmail/etc/defaultdomain</pre>
</blockquote>
<p>Setup the quota warning message that is sent to users when they are at 90%  quota</p>
<p align="left">
<blockquote>
<pre>vi quotawarn.msg</pre>
<blockquote>
<pre><em>From: SomeCompany Postmaster &lt;postmaster@<font color="#ff0066">yourdomain.com</font>&gt;
Reply-To: postmaster@<font color="#ff0066">yourdomain.com</font>
To: SomeCompany User:;
Subject: Mail quota warning
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

Your mailbox on the server is now more than 90% full.

So that you can continue to receive mail,
you need to remove some messages from your mailbox.

If you require assistance with this,
please contact our support department :

  email : support@<font color="#ff0066">yourdomain.com</font>
  Tel   : xx xxxx xxxx</em></pre>
</blockquote>
<pre>cp quotawarn.msg /home/vpopmail/domains/.quotawarn.msg</pre>
</blockquote>
<p>If you want, you can alter the standard message that gets sent to the sender in an overquota situation</p>
<blockquote>
<pre>echo "Message rejected. Not enough storage space in user's mailbox to accept message." &gt; /home/vpopmail/domains/.over-quota.msg</pre>
</blockquote>
<p>OK, vpopmail is now installed!</p>
<p>Some example vpopmail commands :</p>
<blockquote><p>To add a domain :</p>
<blockquote>
<pre>/home/vpopmail/bin/vadddomain <font color="#ff0066">yourdomain.com</font> yourpassword
# this creates the domain and makes a mailbox postmaster@<font color="#ff0066">yourdomain.com</font></pre>
</blockquote>
<p>To add a mailbox:</p>
<blockquote>
<pre>/home/vpopmail/bin/vadduser someone@<font color="#ff0066">yourdomain.com</font> apassword</pre>
<p>(Or you can do it via qmailadmin)</p></blockquote>
<p>To remove a mailbox</p>
<blockquote>
<pre>/home/vpopmail/bin/vdel<span>user</span> someone@<font color="#ff0066">yourdomain.com</font></pre>
<p>(Or you can do it via qmailadmin)</p></blockquote>
<p>To remove a domain :</p>
<blockquote>
<pre>/home/vpopmail/bin/vdeldomain <font color="#ff0066">yourdomain.com</font></pre>
</blockquote>
<p>To change a user&#8217;s password</p>
<blockquote>
<pre>/home/vpopmail/bin/vpasswd someone@<font color="#ff0066">yourdomain.com</font> newpassword</pre>
<p>(Or you can do it via qmailadmin)</p></blockquote>
<p>To lookup info about a user</p>
<blockquote>
<pre>/home/vpopmail/bin/vuserinfo someone@<font color="#ff0066">yourdomain.com</font></pre>
<p>This gives you info such as name, crypted password, cleartext password,    dir, quota, usage%, last auth.<br />
It has a number of flags to let you see the individual fields, or you can see    them all if you dont use any flags.</p>
<p>It also creates the maildirsize file in the users dir</p></blockquote>
</blockquote>
<p>Logging in via POP3</p>
<blockquote><p>When your users are setting up their POP3 email clients (eg Outlook Express),  they should use settings like this :</p>
<blockquote><p>My incoming mail server is a POP3 server<br />
Incoming mail server (POP3): pop3<font color="#ff0066">.yourdomain.com<br />
</font>Outgoing mail server (SMTP): smtp<font color="#ff0066">.yourdomain.com<br />
</font>POP3 account name : <em>theirusername</em>@<font color="#ff0066">yourdomain.com<br />
</font>Password: <em>theirpassword</em></p></blockquote>
<p>When you configured vpopmail, you had the opportunity to nominate a &#8220;default&#8221;  domain. When users from the default domain authenticate, it is optional for them  to add the @<font color="#ff0066">yourdomain.com</font> onto the end of their  username. If vpopmail sees that no domain has been specified by the user, then it will  automatically perform the auth against the nominated default domain. If you are  hosting multiple domains, then everyone who is NOT in the default domain MUST  add their domain name onto the end of their username. (A small percentage of  email programs eg Netscape Mail v4.7 do not permit the use of the @ symbol in  account name. In this case you can use the % symbol instead of the @ symbol)</p></blockquote>
<p><a name="ROAMING_USERS"></a>vpopmail roaming users :</p>
<blockquote><p>With qmail, the typical way to control mail relaying is to put a list of    rules into a file called tcp.smtp. The   <a href="http://cr.yp.to/ucspi-tcp/tcprules.html">tcprules</a> program is then    used to compile this file into <a href="http://cr.yp.to/cdb.html">cdb database    format</a> with the output being stored in a file called tcp.smtp.cdb. The   <a href="http://cr.yp.to/ucspi-tcp/tcpserver.html">tcpserver</a> program is    configured (using the -x parameter) to read this file and thus know which SMTP    clients are permitted to relay mail.</p>
<p>This type of configuration works well if there is a known range of IP    addresses that are permitted to relay mail. eg the IP&#8217;s on the qmail server&#8217;s    local LAN. However if the qmail server needs to provide outbound SMTP services    for clients who may be connecting from any IP, you are going to run into    problems. What is needed is some way to automate the process of granting users    the ability to relay mail, without opening up access to all and sundry on the    Internet.</p>
<p>vpopmail includes a solution for this problem. The solution is known as &#8220;roaming users&#8221; and is typically implemented with a technique known as &#8220;POP-before-SMTP&#8221;. Once a client has successfully authenticated via POP3, vpopmail will add the client&#8217;s IP to a list. vpopmail then merges this list with the contents of the tcp.smtp file and runs the tcprules program to compile a new version of the tcp.smtp.cdb file. Thus the client can now relay mail.</p>
<p>In addition to storing the client&#8217;s IP address, vpopmail will also store    the time of authentication. The postmaster uses a cronjob on the qmail server    to periodically (eg once per hour) run the clearopensmtp program. This program    scans through the list of roaming clients and removes any entries that exceed    the nominated age (eg 3 hours). This ensures that the list of IPs does not    grow out of bounds, and that the roaming IPs are closed within a reasonable    timeframe after being opened.</p>
<p>configure options for vpopmail that relate to roaming users :</p>
<blockquote>
<pre>./configure \
  --enable-roaming-users \              &lt;- enable roaming users functionality
  --enable-tcprules-prog=path \         &lt;- defaults to /usr/local/bin/tcprules
  --enable-tcpserver-file=path \        &lt;- defaults to /home/vpopmail/etc/tcp.smtp
  --enable-relay-clear-minutes=minutes  &lt;- defaults to 180</pre>
</blockquote>
<p>Example /var/qmail/supervise/qmail-smtpd/run file :</p>
<blockquote>
<pre>#!/bin/sh
QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`
exec /usr/local/bin/softlimit -m 2000000 \
  /usr/local/bin/tcpserver -v <strong>-x /home/vpopmail/etc/tcp.smtp.cdb</strong> -c 40 -R \
  -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
  /usr/local/bin/rblsmtpd -b -C -r list.dsbl.org \
  -t 5 \
  /var/qmail/bin/qmail-smtpd 2&gt;&amp;1</pre>
</blockquote>
<p>Notes :</p>
<p>qmail servers are typically built with the tcp.smtp files being located      in the /etc directory. This is not usually suitable for vpopmail roaming      users, since the /etc directory will (should) not have write permissions for      the vpopmail user. Therefore it is not going to be possible for vpopmail to      write out updated versions of the tcp.smtp.cdb file. For use with roaming      users, it is recommended that the tcp.smtp files are stored in ~vpopmail/etc</p>
<p>If a user auths, and their IP already exists in the roaming IP list,      the timestamp for the entry is updated, but the tcprules program is not run.      There is no need to rebuild the tcp.smtp.cdb file as the IP address is      already permitted to relay. Rebuilding the file will only waste disk and CPU      time.</p>
<p>If the vpopmail server is using the default cdb authentication backend, then the list of roaming IPs will be stored in a file called ~vpopmail/etc/open-smtp. If the vpopmail server is using the MySQL backend, the roaming IPs will be stored in a database table called relay. The SQL backend will give better performance on a busy server. Either way though, you should be cautious about enabling roaming user functionality on a very busy server, as a large amount of disk and CPU will be used with the continual rebuilding of the tcp.smtp.cdb file. If the server is busy enough you could run into nasty file locking issues which will cause vpopmail password authentication to intermittently fail. If you absolutely must have POP-before-SMTP functionality on your busy server, then there are only two possible solutions that I can think of  : 1) you could try putting the tcp.smtp files onto a RAM disk, or 2) use vpopmail&#8217;s MySQL auth backend plus use <a href="http://matt.simerson.net/computing/mail/qmail/ucspi-tcp-0.88-mysql.patch">Matt Simerson&#8217;s tcpserver patch</a> that      allows all of the tcp.smtp files to be stored in MySQL</p>
<p>For POP-before-SMTP to work, the POP3 daemon will need to run under the      tcpserver program. This is because vpopmail uses tcpserver&#8217;s TCPREMOTEIP      environment variable to work out what IP address the POP3 user is connecting      from.</p>
<p>Over time POP-before-SMTP is becoming a less favored way of      allowing roaming users to relay mail. SMTP-Auth appears to becoming the more      preferred option, as it scales much more easily on a busy server. However      for a small to medium sized server, POP-before-SMTP is still quite a      workable option. If you would like investigate the use of SMTP-Auth take a      look at this patch     <a href="http://www.fehcom.de/qmail/smtpauth.html#PATCHES">     http://www.fehcom.de/qmail/smtpauth.html#PATCHES</a></p>
<p>IMAP-before-SMTP is possible when using Courier-IMAP v3.x. However it only works when configured &#8220;&#8211;with-authvchkpw &#8211;without-authdaemon&#8221;. When running &#8211;without-authdaemon, Courier-IMAP&#8217;s authvchkpw code is able to make use of vpopmail&#8217;s roaming user functions to allow IMAP-before-SMTP functionality. IMAP-before-SMTP is not possible when Courier-IMAP has been complied &#8211;with-authdaemon, because in this mode the user&#8217;s IP address is not made available to the authvchkpw code (via the TCPREMOTEIP env var). Also note that in Courier-IMAP v4.x and later, &#8211;without-authdaemon functionality is no longer available thus preventing IMAP-before-SMTP from working.</p></blockquote>
<hr />
<h3><a name="AUTORESPONDER"></a>AUTORESPONDER</h3>
<p>Current development location : <a href="http://www.sourceforge.net/projects/qmailadmin"> http://www.sourceforge.net/projects/qmailadmin</a></p>
<p>This package is a prerequisite for qmailadmin.</p>
<p>Download and unpack the source</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/qmailadmin/autorespond-2.0.4.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/qmailadmin/autorespond-2.0.4.tar.gz</a>
tar xzf autorespond-2.0.4.tar.gz
chown -R root.root autorespond-2.0.4
cd autorespond-2.0.4</pre>
</blockquote>
<p>Build the program</p>
<blockquote>
<pre>make
make install</pre>
</blockquote>
<p>Notes :</p>
<blockquote><p>Qmailadmin uses the autorespond program for both autoresponse (&#8220;mail robot&#8221;    in qmailadmin-speak), and vacation response duties. However this is pretty    badly FUBAR. Reason being is the autorespond.c is written to do duties as an    autoresponse program only. &#8220;Out of the box&#8221; it doesn&#8217;t behave correctly when    doing vacation response duties. The code inside the program can be easily    tweaked to work correctly as a vacation responder, but this will break the    autoresponder functionality. Unfortunately the settings are mutually    exclusive. In my opinion the correct solution is to create two variations of    this program, autorespond.c and vacation.c, install them both, and then tweak    qmailadmin to call the right binary for the right job. I have opened   <a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1156347&amp;group_id=6691&amp;atid=106691">   a bug report on the qmailadmin sourceforge site</a> to try and get this    problem sorted out. If you read back through the qmailadmin and vpopmail    archives, you will see the the autoresponder stuff is an ongoing saga <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />ps. Inter7 have got a modified version of the autorespond program,    which I believe has been coded to work correctly as a vacation responder <a href="http://inter7.com/devel/autorespond-2.0.5.tar.gz">http://inter7.com/devel/autorespond-2.0.5.tar.gz</a></p></blockquote>
<h3><a name="EZMLM"></a>EZMLM / EZMLM-IDX</h3>
<p>This package is a prerequisite for qmailadmin</p>
<p>ezmlm is mailing list software written by the author of qmail<br />
ezmlm-idx is patch that adds extra features to the standard ezmlm program.</p>
<p>EZMLM : <a href="http://cr.yp.to/ezmlm.html">http://cr.yp.to/ezmlm.html</a></p>
<p>EZMLM-IDX PATCH : <a href="http://www.ezmlm.org/">http://www.ezmlm.org</a>  <font size="2"><br />
(although I often find this site unresponsive, and so I use one of the mirrors  instead like <a href="http://www.glasswings.com.au/ezmlm/"> http://www.glasswings.com.au/ezmlm/</a>)</font></p>
<p>Download and unpack the ezmlm sources</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://cr.yp.to/software/ezmlm-0.53.tar.gz">http://cr.yp.to/software/ezmlm-0.53.tar.gz</a>
tar xzf ezmlm-0.53.tar.gz
chown -R root.root ezmlm-0.53</pre>
<pre>wget <a href="http://www.bowe.id.au/michael/Sources/Linux/WebMail/ezmlm-idx-0.40.tar.gz">http://www.bowe.id.au/michael/Sources/Linux/WebMail/ezmlm-idx-0.40.tar.gz</a>
tar xzf ezmlm-idx-0.40.tar.gz
chown -R root.root ezmlm-idx-0.40</pre>
</blockquote>
<p>Merge the sources together</p>
<blockquote>
<pre>cp -R ezmlm-idx-0.40/* ezmlm-0.53/
# (you need to press y quite a few times to allow the patch files to overwrite the original files)</pre>
<pre>cd ezmlm-0.53
patch &lt; idx.patch</pre>
</blockquote>
<p>Build the program</p>
<blockquote>
<pre>make
make man
make setup</pre>
</blockquote>
<h3><a name="QMAILADMIN"></a>QMAILADMIN</h3>
<p>Original Authors : <a href="http://www.inter7.com/qmailadmin"> http://www.inter7.com/qmailadmin</a><br />
Current Development location  : <a href="https://sourceforge.net/projects/qmailadmin/"> https://sourceforge.net/projects/qmailadmin/</a></p>
<p>Description :</p>
<blockquote><p>The <strong>domain postmaster</strong> can use this tool to view all the accounts on    the domain as well as add/remove accounts, forwards, auto-responders etc.</p>
<p><strong>Domains users</strong> can use this tool to modify their own user settings    only. ie mailbox password, real name, forwards, vacations.</p>
<p>This tool does not let you create new domains.</p></blockquote>
<p>Download and unpack the source</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/qmailadmin/qmailadmin-1.2.9.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/qmailadmin/qmailadmin-1.2.9.tar.gz</a>
<span>tar xzf qmailadmin-1.2.9.tar.gz</span>
chown -R root.root qmailadmin-<span>1.2.9</span>
cd qmailadmin-<span>1.2.9</span></pre>
</blockquote>
<p>(Optional) Make a small mod that affects the look of the qmailadmin login  page</p>
<blockquote><p>edit the lang/en file, and change record 112 &#8220;Username&#8221; rather than &#8220;User    Account&#8221;<br />
(We found our users knew what to type as their &#8220;Username&#8221;, but didn&#8217;t know    what to type as a &#8220;User Account&#8221;)</p></blockquote>
<p>Build the program</p>
<blockquote>
<pre>./configure \
  --enable-htmldir=/usr/local/apache/htdocs \
  --enable-cgibindir=/usr/local/apache/cgi-bin \
  --enable-maxusersperpage=12 \
  --enable-maxaliasesperpage=12 \
  --disable-modify-quota \
  --disable-ezmlm-mysql \
  --disable-help</pre>
<pre># note, I chose to have 12 accounts per page in the config above,
# because this makes these particular screens fit nicely on my 1024*768 monitor</pre>
<pre>make
make install-strip</pre>
</blockquote>
<p>Test to see if it works</p>
<blockquote>
<pre>http://webmail.<font color="#ff0066">yourdomain.com</font>/cgi-bin/qmailadmin</pre>
<p>If you login a domain postmaster, then you should get the screens where you    can view all and add/remove mailboxes, aliases, mailinglists etc on the    domain. etc</p>
<p>If you login as a user, you can only access your own mailbox settings (eg    password, forwards, vacation messages)</p></blockquote>
<p>Setting limits :</p>
<blockquote><p>You can setup limits on any domains where required by putting a <strong>.qmailadmin-limits</strong>  file into the domain&#8217;s virtual dir (/home/vpopmail/domains/<font color="#ff0066">yourdomain.com</font>). Make sure vpopmail user has read  permissions for this file.</p>
<p>Syntax of .qmailadmin-limits file is as follows :</p>
<blockquote>
<pre>maxpopaccounts X
maxforwards X
maxmailinglists X
maxautoresponders X</pre>
</blockquote>
<p>Set X to be the maximum desired number for that feature<br />
Set X to be 0 if you want to disable that feature &amp; menu item</p>
<p>There are also some other settings that can be specified in the .qmailadmin-limits  file, refer to section 6 of the qmailadmin installation instructions (<a href="http://inter7.com/qmailadmin/install.txt">http://inter7.com/qmailadmin/install.txt</a>)  for more info</p></blockquote>
<p>A bit of a long-winded misc note to myself  :</p>
<blockquote><p>(If you are setting up your vpopmail server for the first time, then this  block of text has no relevance to you. You can skip straight past this waffle  and go onto  the next section&#8230;)</p>
<p>As of qmailadmin-1.0.21, you cant create &#8220;aliases&#8221; any more. What qmailadmin  previously created as aliases, are now created as forwards. Aliases dump  incoming mail for that aliased address directly into the recipient user&#8217;s  Maildir. The problem with this is it bypassed any further &#8220;.qmail&#8221; processing,  meaning that you ran into problems if you were trying to setup some of the more  fancy things (like per-user SpamAssassin configurations?). Using forwards  bypasses this problem as the message will get re-injected back into the queue  for delivery.</p>
<p>However this change does cause some problems for sites that already have  existing aliases in use. The problem is that when you go into qmailadmin-1.0.21  and select the forwards screen, all the existing aliases and forwards for that  domain are displayed.</p>
<p>Problem # 1 : For mail that is being redirected to a local account, you can&#8217;t  tell from this screen whether the user is getting alias or forward delivery. If  you were trying to setup some tricky per-user stuff, then you are going to get  variable results because some users may be configured as alias, and others are  configured as forward, but you cant easily tell which is which from this screen</p>
<p>Problem # 2 : Up the top there is a count showing &#8220;[Used # / limit]&#8220;. This  count relates to the number of forwards in use and the maxforwards qmailadmin-limits  setting. The count ignores any existing aliases. This could potentially cause  confusion for domain postmasters as you will be looking at a screen full of  accounts and if some of them have been previously setup as aliases then it is  going to be hard to reconcile the reported count against the number of accounts  displayed on the screen</p>
<p>What is needed is some sort of utility that will scan and find existing  aliases and convert them over to the now-preferred forward syntax&#8230;. That would  keep the delivery method consistent for all users, and would also eliminate any  problems with the qmailadmin-limits code</p>
<p>Note: As of qmailadmin-1.0.25, there  is a tool for converting existing aliases to forwards. Look in the contrib dir  for the tools called alias2forward.pl</p></blockquote>
<p><a name="VALIAS_PROCESSING"></a>valias processing :</p>
<blockquote><p>qmailadmin v1.2.1 and later store aliases and autoresponders in valias table  if vpopmail was compiled with &#8211;enable-valias. If you are upgrading from a  previous version of QmailAdmin and used the &#8211;enable-valias option when building  vpopmail, be sure to download vpopmail 5.4.1 or later and use the  dotqmail2valias program to convert .qmail-alias files to valias table entries.</p></blockquote>
<hr />
<h3><a name="COURIER_IMAP"></a>COURIER IMAP</h3>
<p><a href="http://www.courier-mta.org/imap/">http://www.courier-mta.org/imap/</a></p>
<p>Courier-IMAP is an IMAP server. Having an IMAP server is a prerequisite to be  able run a IMAP-client WebMail system like SquirrelMail. Courier-IMAP is good  choice because it has support for vpopmail authentication and maildir mailboxes.</p>
<p>Download and unpack the authentication library</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.58.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-authlib-0.58.tar.bz2</a>
bunzip2 courier-authlib-0.58.tar.bz2
tar xf courier-authlib-0.58.tar
chown -R root.root courier-authlib-0.58
cd courier-authlib-0.58</pre>
</blockquote>
<p>Build the authentication library</p>
<blockquote>
<pre>./configure \
  --prefix=/usr/local/courier-authlib \
  --without-authpam \
  --without-authldap \
  --without-authpwd \
  --without-authmysql \
  --without-authpgsql \
  --without-authshadow \
  --without-authuserdb \
  --without-authcustom \
  --without-authcram \
  --without-authpipe \
  --with-authdaemon \
  --with-authvchkpw</pre>
<pre># note, if you are running redhat/fedora, you may have to add a
#   --with-redhat
# to the list of configuration settings above</pre>
<pre>make
make install
make install-configure</pre>
</blockquote>
<p>Review the settings for the authentication library</p>
<blockquote>
<pre>vi /usr/local/courier-authlib/etc/authlib/authdaemonrc</pre>
<blockquote>
<table style="border-collapse:collapse;" border="1" cellspacing="0" width="1189">
<tr>
<td width="254">
<pre>authmodulelist="authvchkpw"</pre>
</td>
<td width="928">
<pre>&lt;-- Authenticate via vpopmail</pre>
</td>
</tr>
</table>
</blockquote>
</blockquote>
<p>Configure the authentication library so it is running all the time from bootup onwards</p>
<blockquote>
<pre><font face="Courier New">cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
chmod 744 /etc/rc.d/init.d/courier-authlib</font></pre>
<pre>chkconfig --add courier-authlib</pre>
<p>Then I like to use the <font face="Courier" size="2">ntsysv</font> program    to double-check that courier-authlib is set to launch at boot time</p></blockquote>
<p>If you aren&#8217;t ready to reboot the server now, you can fire up the    authentication libraries in the mean time with this command :</p>
<blockquote>
<pre>/etc/rc.d/init.d/courier-authlib start</pre>
</blockquote>
<p>At this point the courier-authlib software should be running. A good way to verify    this is to use this command :</p>
<blockquote>
<pre>ps axf</pre>
</blockquote>
<p>And if all is well, you should be able to see something like this :</p>
<blockquote>
<pre>23689 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/usr/local/courier-authlib/var/spool/
23690 ? S 0:00  \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
23702 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
23703 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
23704 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
23705 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
23706 ? S 0:00      \_ /usr/local/courier-authlib/libexec/courier-authlib/authdaemond</pre>
</blockquote>
<p><img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" />FAM + Courier-IMAP on Redhat  7.3 doesnt seem very stable. On old Linux platforms, I would recommend you  remove FAM before trying to install Courier-IMAP ( By the way, the  alternative/replacement package GAMIN seems to works OK with Courier-IMAP on  newer platforms like FC4/FC5/CentOS43)</p>
<blockquote>
<pre>rpm -e fam fam-devel</pre>
</blockquote>
<p>Download and unpack the courier-IMAP source</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.1.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/courier-imap-4.1.1.tar.bz2</a>
bunzip2 courier-imap-4.1.1.tar.bz2
tar xf courier-imap-4.1.1.tar
chown -R root.root courier-imap-4.1.1
cd courier-imap-4.1.1</pre>
</blockquote>
<p>Build the program</p>
<blockquote>
<pre>COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig \
CPPFLAGS=-I/usr/local/courier-authlib/include \
./configure \
  --prefix=/usr/local/courier-imap \
  --disable-root-check \
<span style="background-color:#00ff00;">  --with-ssl</span></pre>
<pre># note, if you are running redhat/fedora, you may have to add a
#   --with-redhat
# to the list of configuration settings above</pre>
<pre>make
make install
make install-configure</pre>
</blockquote>
<p>The Courier-IMAP package includes 4 servers that can be individually    enabled/disabled : IMAP, IMAP-SSL, POP3, POP3SSL. In this example, we are only    using the IMAP server.</p>
<blockquote>
<pre>vi /usr/local/courier-imap/etc/imapd</pre>
<blockquote>
<table style="border-collapse:collapse;" border="1" cellspacing="0" width="1189">
<tr>
<td width="254">
<pre>MAXDAEMONS=40
MAXPERIP=40
IMAP_EMPTYTRASH=Trash:7,Sent:30
IMAPDSTART=YES</pre>
</td>
<td width="928">
<pre>&lt;-- Max number of IMAP daemons
&lt;-- All connections will be coming from single IP (SquirrelMail on localhost)
&lt;-- Enable automatic purging of mail from these folders
&lt;-- allow our init.d script (below) to boot up the imapd</pre>
</td>
</tr>
</table>
</blockquote>
</blockquote>
<p>Configure Courier-IMAP so it is running all the time from bootup onwards</p>
<blockquote>
<pre><font face="Courier New">cp courier-imap.sysvinit /etc/rc.d/init.d/courier-imap
chmod 744 /etc/rc.d/init.d/courier-imap</font></pre>
<pre>chkconfig --add courier-imap</pre>
<p>Then I like to use the <font face="Courier" size="2">ntsysv</font> program    to double-check that courier-imap is set to launch at boot time</p></blockquote>
<p>If you aren&#8217;t ready to reboot the server now, you can fire up Courier-IMAP    in the mean time with this command :</p>
<blockquote>
<pre>/etc/rc.d/init.d/courier-imap start</pre>
</blockquote>
<p>At this point the Courier-IMAP software should be running. A good way to verify    this is to use this command :</p>
<blockquote>
<pre>ps axf</pre>
</blockquote>
<p>And if all is well, you should be able to see something like this :</p>
<blockquote>
<pre>1030 ? S 0:02 /usr/local/courier-imap/libexec/authlib/authdaemond.plain start
1031 ? S 1:00  \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start
1032 ? S 0:59  \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start
1033 ? S 1:01  \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start
1035 ? S 1:02  \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start
1036 ? S 1:02  \_ /usr/local/courier-imap/libexec/authlib/authdaemond.plain start
17566 ? S 0:00 /usr/local/courier-imap/libexec/couriertcpd -address=0 -stderrlogger=/usr/local/courier-
17569 ? S 0:00 /usr/local/courier-authlib/sbin/courierlogger imapd</pre>
</blockquote>
<hr />
<table style="border-collapse:collapse;" border="1" cellpadding="2">
<tr>
<td bgcolor="#c0c0c0">
<h3><img src="http://www.bowe.id.au/images/undercon.gif" border="0" height="38" width="40" />SQWEBMAIL</h3>
<p>SqWebMail is a webmail program written by the authors of Courier-Authlib/Courier-IMAP.      Most webmail packages use POP3 or IMAP, but SqWebMail is a bit different &#8211;      it accesses the Maildirs directly.</p>
<p>I wouldn&#8217;t really recommend SqWebMail ( you are better off using the      Squirrelmail instructions below). But I regularly see people asking how to      install SqWebMail, so I am going to add some notes here to show what the      required steps would be if you chose to use this package instead of Courier-IMAP      / Squirrelmail. I wont go into a heap of detail, but here are the steps you      would need to follow</p>
<p>Note, to run SqWebMail, you still need to have Courer-Authlib installed      as per the instructions above, but you don&#8217;t have to install Courier-IMAP.      You can run Courier-IMAP if you want, it wont interfere with SqWebMail.</p>
<blockquote>
<pre>mkdir -p /usr/local/apache/htdocs/images/sqwebmail</pre>
<pre>echo '#!/bin/sh' &gt; /usr/local/bin/sqwebmail-banner.sh
echo '##' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo '## This progam is called by sqwebmail for each [#B#] tag in the html templates' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo '## The ARGV[0] will be the name of the html template that launched the call' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo '##' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
echo 'echo "&lt;center&gt;YourISP support - call xxxx xxxx&lt;/center&gt;"' &gt;&gt; /usr/local/bin/sqwebmail-banner.sh
chmod 755 /usr/local/bin/sqwebmail-banner.sh</pre>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/courier/sqwebmail-5.1.1.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/sqwebmail-5.1.1.tar.bz2</a></pre>
<pre>tar xjf sqwebmail-5.1.1.tar.bz2
chown -R root.root sqwebmail-5.1.1
cd sqwebmail-5.1.1</pre>
<pre>COURIERAUTHCONFIG=/usr/local/courier-authlib/bin/courierauthconfig \
CPPFLAGS=-I/usr/local/courier-authlib/include \
./configure \
  --prefix=/usr/local/sqwebmail \
  --disable-autorenamesent \
  --enable-cgibindir=/usr/local/apache/cgi-bin/ \
  --enable-imagedir=/usr/local/apache/htdocs/images/sqwebmail/ \
  --enable-imageurl=/images/sqwebmail \
  --with-maxformargsize=17500000 \
  --with-maxmsgsize=18000000 \
  --enable-bannerprog=/usr/local/bin/sqwebmail-banner.sh</pre>
<pre># If you get a pcre error during sqwebmail configure, you will probably need to do this :
# cd /usr/local/src
# wget <a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-6.4.tar.gz">ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-6.4.tar.gz</a>
# tar xzf pcre-6.4.tar.gz
# chown -R root.root pcre-6.4
# cd pcre-6.4
# ./configure
# make
# make install</pre>
<pre>make
make install
make install-configure</pre>
<pre>echo "<font color="#ff0066">yourdomain.com</font>" &gt; /usr/local/sqwebmail/etc/hostname</pre>
<pre># Add a line like this to your httpd.conf, to workaround MSIE bugs
BrowserMatch "MSIE" nokeepalive downgrade-1.0 force-response-1.0</pre>
<pre>crontab -e</pre>
<blockquote>
<pre># Purge sqwebmail cache files once per hour
0 * * * * /usr/local/sqwebmail/share/sqwebmail/cleancache.pl</pre>
</blockquote>
<pre>vi /etc/rc.d/rc.local</pre>
<blockquote>
<pre>/usr/local/sqwebmail/libexec/sqwebmaild.rc start</pre>
</blockquote>
</blockquote>
<p>To access SqWebMail, the URL would be     <a href="http://webmail.yourdomain.com/cgi-bin/sqwebmail">http://webmail.<font color="#ff0066">yourdomain.com</font>/cgi-bin/sqwebmail</a></p>
<p>To customise look/feel, you can modify the HTML files in /usr/local/sqwebmail/share/sqwebmail/html/en,      and also the css file /usr/local/apache/htdocs/images/sqwebmail</td>
</tr>
</table>
<hr />
<h3><a name="SQUIRRELMAIL"></a>SQUIRRELMAIL</h3>
<p><a href="http://www.squirrelmail.org/">www.squirrelmail.org</a></p>
<p>the text with yellow background is specific to using MySQL backend. if you  don&#8217;t want to use MySQL backend, then just skip over these sections&#8230;.</p>
<p>Go to the <a href="http://www.squirrelmail.org/download.php">SquirrelMail  download page</a>, and save the latest source to /usr/local/src. In this example  I have used :</p>
<blockquote>
<pre>squirrelmail-1.4.4.tar.gz</pre>
</blockquote>
<p>Download and unpack all the sources</p>
<blockquote>
<pre>cd /usr/local/apache/htdocs
tar xzf /usr/local/src/squirrelmail-1.4.4.tar.gz
chown -R root.www squirrelmail-1.4.4
chmod -R 750 squirrelmail-1.4.4
ln -s squirrelmail-1.4.4 squirrelmail</pre>
</blockquote>
<p>Create the required directory structure</p>
<blockquote>
<pre>mkdir /var/squirrelmail
# create the data dir. This is where users personal preferences are stored if not using MySQL backend
mkdir /var/squirrelmail/data
# create the attach dir. This is where temp files for emails in progress are store
mkdir /var/squirrelmail/attach</pre>
<pre>cd squirrelmail
cp data/default_pref /var/squirrelmail/data
chown -R root.www /var/squirrelmail
chmod -R 0770 /var/squirrelmail/data
chmod -R 0730 /var/squirrelmail/attach</pre>
</blockquote>
<p>SquirrelMail allows you to add your company logo to the login page. So    whack a copy of your logo into the Apache images directory so it is available    for SquirrelMail to use</p>
<blockquote>
<pre>cp /usr/local/src/yourcompanylogo-100.gif /usr/local/apache/htdocs/images</pre>
</blockquote>
<p>Configure SquirrelMail</p>
<blockquote>
<pre>cd config
perl conf.pl</pre>
<blockquote>
<pre>D. SET PRE-DEFINED SETTINGS FOR SPECIFIC IMAP SERVERS
  Choose Courier</pre>
<pre>1. ORGANIZATION PREFERENCES
  1.  Organization name            : YourCompany WebMail
  2.  Organization Logo            : /images/yourcompanylogo-100.gif
  3.  Org. Logo Height/Width       : 100/100
  4.  Organization title           : YourCompany WebMail (v$version)
  7.  Provider link                : http://www.<font color="#ff0066">yourdomain</font>.com
  8.  Provider name                : YourCompany</pre>
<pre>2. SERVER SETTINGS
  1.  Domain                       : <font color="#ff0066">yourdomain.com</font></pre>
<pre>3. FOLDER DEFAULTS
  15. Default Unseen Type          : 2</pre>
<pre>4. GENERAL OPTIONS
  1.  Data directory               : /var/squirrelmail/data
  2.  Attachment directory         : /var/squirrelmail/attach
  5.  Usernames in lower case      : true
  7.  Hide SM attributions         : true
  11. Allow server-side sorting    : false
  ( Note, server-sorting is faster, but I personally find the sort results to be not as "intuitive"
   compared with when you let SquirrelMail do the sorting. If you toggle this option on/off and compare
   the resultant displays in SquirrelMail you will see what I mean. For example if you server-sort the
   FROM column then the sort will be done senders email address, whereas if you let SquirrelMail do the
   sort then column will be sorted on senders name. I would suggest you try toggling this
   option on and off to make your own decision on which sorting method provides the better results.)</pre>
<pre>6. ADDRESS BOOKS
  2. Use Javascript Address Book Search : True</pre>
<pre><span style="background-color:#ffff00;">9. DATABASE
  1.  DSN for address book : mysql://<em>squirreluser</em>:<em>squirrelpassword</em>@localhost/squirrelmail
  3.  DSN for preferences  : mysql://<em>squirreluser</em>:<em>squirrelpassword</em>@localhost/squirrelmail</span></pre>
<pre>Now Save and quit the config program</pre>
</blockquote>
</blockquote>
<p><span style="background-color:#ffff00;">Create the necessary database and tables in MySQL,  so that SquirrelMail can store the address books and user preferences there  :</span></p>
<blockquote>
<pre><span style="background-color:#ffff00;">cd /usr/local/mysql/bin</span></pre>
<pre><span style="background-color:#ffff00;">./mysql --password="<em>mysql-root-</em></span><em><span style="background-color:#ffff00;">pwd</span></em><span style="background-color:#ffff00;">"</span></pre>
<blockquote>
<pre><span style="background-color:#ffff00;">CREATE DATABASE squirrelmail;</span></pre>
<pre><span style="background-color:#ffff00;">GRANT select,insert,update,delete ON squirrelmail.*
TO <em>squirreluser</em>@localhost IDENTIFIED BY '<em>squirrelpassword</em>';</span></pre>
</blockquote>
</blockquote>
<blockquote>
<blockquote>
<pre><span style="background-color:#ffff00;">USE squirrelmail;</span></pre>
<pre><span style="background-color:#ffff00;">CREATE TABLE address (
  owner varchar(128) DEFAULT '' NOT NULL,
  nickname varchar(16) DEFAULT '' NOT NULL,
  firstname varchar(128) DEFAULT '' NOT NULL,
  lastname varchar(128) DEFAULT '' NOT NULL,
  email varchar(128) DEFAULT '' NOT NULL,
  label varchar(255),
  PRIMARY KEY (owner,nickname),
  KEY firstname (firstname,lastname)
);</span></pre>
<pre><span style="background-color:#ffff00;">CREATE TABLE userprefs (
  user varchar(128) DEFAULT '' NOT NULL,
  prefkey varchar(64) DEFAULT '' NOT NULL,
  prefval blob DEFAULT '' NOT NULL,
  PRIMARY KEY (user,prefkey)
);</span></pre>
<pre><span style="background-color:#ffff00;">quit</span></pre>
</blockquote>
</blockquote>
<p>You can define what default SquirrelMail settings that users will receive  when they log in.</p>
<blockquote><p>For MySQL backend</p>
<blockquote>
<pre><span style="background-color:#ffff00;">cd /usr/local/apache/htdocs/squirrelmail
# replace the default preferences definition in the db_prefs file
# with our own customised defaults.
# Open the file, scroll down and replace the existing "var $default"
# entry (on line 102) with our customised version shown below
vi functions/db_prefs.php</span></pre>
<blockquote>
<pre><span style="background-color:#ffff00;">var $default = Array('chosen_theme' =&gt; '../themes/default_theme.php',
  'show_html_default' =&gt; '1',
  'language' =&gt; 'en_US',
  'use_javascript_addr_book' =&gt; '1',
  'left_size' =&gt; '140',
  'left_refresh' =&gt; '3600',
  'show_username' =&gt; '1',
  'show_username_pos' =&gt; 'top',
  'order1' =&gt; '1',
  'order2' =&gt; '2',
  'order3' =&gt; '3',
  'order4' =&gt; '5',
  'order5' =&gt; '4',
  'order6' =&gt; '6');</span></pre>
</blockquote>
</blockquote>
<p>Or, if you aren&#8217;t running MySQL backend for SquirrelMail, you can adjust    the default preferences like this :</p>
<blockquote>
<pre>vi /var/squirrelmail/data/default_pref :</pre>
<blockquote><p>show_html_default=1<br />
language=en_US<br />
use_javascript_addr_book=1<br />
left_size=140<br />
left_refresh=3600<br />
show_username=1<br />
show_username_pos=top<br />
order1=1<br />
order2=2<br />
order3=3<br />
order4=5<br />
order5=4<br />
order6=6</p></blockquote>
</blockquote>
</blockquote>
<p>Setup periodic purging of the &#8220;attach&#8221; directory</p>
<blockquote><p>When SquirrelMail users are composing a message that has attachment(s), the    attachment is temporarily stored in the /var/squirrelmail/attach directory.     When the user sends the message, the associated temp files will get deleted.</p>
<p>However sometimes the temp files do not get deleted (eg if the user closes    their browser mid-compose?).  Since the permissions on this directory are    setup (as a security measure) to prevent the webserver from listing the files    in this directory, there is no way for Apache/SquirrelMail to do a periodic    scan/purge of old files.</p>
<p>So we are going to setup a daily crontab to clean up any attachments that    get left hanging around</p>
<blockquote>
<pre>crontab -e</pre>
<blockquote>
<pre># delete any files that are more than 2 days old from the SquirrelMail attachment dir
0 0 * * * find /var/squirrelmail/attach/* -atime +2 -exec /bin/rm {} \;</pre>
</blockquote>
</blockquote>
</blockquote>
<p>Install the quota_usage plugin so users can see their mailbox quota usage</p>
<blockquote>
<pre>cd /usr/local/src
wget <a href="http://www.squirrelmail.org/plugins/quota_usage-1.2.tar.gz">http://www.squirrelmail.org/plugins/quota_usage-1.2.tar.gz</a>
wget <a href="http://www.squirrelmail.org/plugins/compatibility-1.3.tar.gz">http://www.squirrelmail.org/plugins/compatibility-1.3.tar.gz</a></pre>
<pre>cd /usr/local/apache/htdocs/squirrelmail/plugins
tar xzf /usr/local/src/quota_usage-1.2.tar.gz
cp quota_usage/config.php.sample quota_usage/config.php
chown -R root.www quota_usage
chmod -R o-rx quota_usage</pre>
<pre># qmailadmin and the other tools all classify a 1Mb as 1048576 bytes (1024 * 1024 )
# Fix up the quota_plugin so it works with the same units.
# Otherwise your quota would show as 20M in qmailadmin, and 21M in SquirrelMail  :-/
vi quota_usage/functions.php</pre>
<blockquote>
<pre>Go to line 43 and change the value 1000000 to 1048576</pre>
</blockquote>
<pre>tar xzf /usr/local/src/compatibility-1.3.tar.gz
chown -R root.www compatibility
chmod -R o-rx compatibility</pre>
<pre>cd ../config
perl conf.pl
8. Plugins
      choose quota_usage
      choose compatibility</pre>
</blockquote>
<p><span style="background-color:#00ff00;">Optionally, Setup SSL mode at login  time</span></p>
<blockquote>
<pre><span style="background-color:#00ff00;">cd /usr/local/src
wget <a href="http://www.squirrelmail.org/plugins/secure_login-1.0-1.2.8.tar.gz">http://</a><a href="http://www.squirrelmail.org/plugins/secure_login-1.2-1.2.8.tar.gz">www.squirrelmail.org/plugins/secure_login-1.2-1.2.8.tar.gz</a> </span></pre>
<pre><span style="background-color:#00ff00;">cd /usr/local/apache/htdocs/squirrelmail/plugins
tar xzf /usr/local/src/secure_login-1.2-1.2.8.tar.gz
cp secure_login/config.php.sample secure_login/config.php
chown -R root.www secure_login
chmod -R o-rx secure_login
</span></pre>
<pre><span style="background-color:#00ff00;">cd ../config
perl conf.pl
8. Plugins, and choose secure_login</span></pre>
<pre></pre>
</blockquote>
<p>Optionally, modify SquirrelMail so that it will any failed login attempts to  the syslog</p>
<blockquote><p>modify squirrelmail/functions/imap_general.php</p>
<blockquote><p>search for the line that has &#8220;Unknown user or password incorrect&#8221;<br />
above this line add :</p>
<blockquote>
<pre>syslog(LOG_MAIL|LOG_NOTICE,"Squirrelmail login failed for Username : $username, Password : $password");</pre>
</blockquote>
<p>now failed SquirrelMail logins will be logged to /var/log/maillog       <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p></blockquote>
</blockquote>
<p>We also added some code to squirrelmail/src/login.php to add a notes page to  the login screen. We inserted this chunk just before the line that says &#8220;do_hook(&#8216;login_bottom&#8217;);</p>
<blockquote>
<pre>echo "&lt;BR&gt;&lt;CENTER&gt;".
"&lt;TABLE BORDER=1 WIDTH=75%&gt;&lt;TR&gt;&lt;TD ALIGN=CENTER&gt;&lt;FONT FACE=Arial SIZE=2&gt;".
"&lt;P&gt;&lt;B&gt;&lt;FONT SIZE=3&gt;IMPORTANT NOTES REGARDING THE WEBMAIL SYSTEM&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;".
"&lt;P&gt;&lt;B&gt;AUTOMATIC MAIL DELETION&lt;/B&gt;&lt;/P&gt;".
"&lt;P&gt;The mail server will automatically delete mail from the&lt;BR&gt; ".
"following folders after the specified number of days :&lt;br&gt;".
"Trash Folder - 7 days, Sent Folder - 30 days".
"&lt;P&gt;&lt;B&gt;POP3 MAIL CLIENTS&lt;/B&gt;&lt;/P&gt;".
"&lt;P&gt;If you check your mail using a POP3 mail client (such as Outlook Express),&lt;BR&gt; ".
"it will download and delete the mail from your WebMail inbox.&lt;/P&gt;".
"&lt;P&gt;If you want to be able to download the mail using POP3 and also&lt;BR&gt; ".
"leave it on the server so you can see it with WebMail, you will need&lt;BR&gt; ".
"to adjust the settings in your POP3 client to tell it not to delete&lt;BR&gt; ".
"mail after downloading.&lt;/P&gt;".
"&lt;P&gt;For example, to configure this in Outlook Express you would go to&lt;br&gt; ".
"&lt;i&gt;Tools -&gt; Accounts -&gt; Mail -&gt; Properties -&gt; Advanced&lt;/i&gt;&lt;BR&gt; ".
"and then tick the box&lt;BR&gt;&lt;i&gt;'Leave a copy of message on server'&lt;/i&gt;&lt;P&gt;".
"&lt;/FONT&gt;".
"&lt;/TD&gt;&lt;TR&gt;&lt;/TABLE&gt;&lt;/CENTER&gt;";</pre>
</blockquote>
<p>Now, another cosmetic change&#8230; : modify the squirrelmail/src/login.php and  change the wording of &#8220;Name:&#8221; to &#8220;Email address:&#8221;.</p>
<p>Next, we setup a default document in the web servers root, to redirect our  customers through to the SquirrelMail login page. That way when people want to  access the WebMail tool they can point their browser to &#8220;http://webmail.<font color="#ff0066">yourdomain.com</font>&#8221; and they will get automatically  redirected through to the SquirrelMail directory</p>
<blockquote>
<pre>vi /usr/local/apache/htdocs/index.html</pre>
<blockquote>
<pre>&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Redirect to WebMail login screen...&lt;/TITLE&gt;
&lt;META HTTP-EQUIV="refresh" CONTENT="1; url=http://webmail.<font color="#ff0066">yourdomain.com</font>/squirrelmail/"&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
Redirecting to the WebMail login screen...&lt;br&gt;
&lt;a href=squirrelmail/&gt;Click here if you are not automatically redirected&lt;/a&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;</pre>
</blockquote>
</blockquote>
<hr />
<h3><a name="SPAM_VIRUS"></a>SPAM AND VIRUS CHECKING</h3>
<p>OK, now you have a working mail server.. You have loaded all your users and  they are giving the new system a good workout. Everything is running nice and  smoothly. You sit back and think &#8220;my job is done!&#8221;</p>
<p>Until&#8230; users starting coming to you and saying&#8230; &#8220;Hey, this new mail  server is really good&#8230; But how do I block out all these viruses and spam?&#8221;&#8230;  Uh oh&#8230;!</p>
<p>Well, luckily the answer is relatively easy&#8230;.. The qmail-scanner program  lets us easily implement anti-spam and anti-virus. Installation instructions  follow :</p>
<p><strong> OPTIONAL : RAZOR V2</strong></p>
<p><a href="http://razor.sourceforge.net/">http://razor.sourceforge.net</a></p>
<p>If Razor is installed, SpamAssassin will automatically include it in the list  of tests run. We found that Razor is quite accurate in identifying spam, and it  only added small amount of extra CPU load on the server, so it is definitely  worth installing. Note though,  that I believe the licensing of Razor states that it isn&#8217;t free for commercial  use &#8211; so you should probably check the docs before deciding whether you wish to  enable this function or not</p>
<p>Compile and install :</p>
<blockquote>
<pre># install the pre-requisite modules for razor
perl -MCPAN -e shell</pre>
<blockquote>
<pre>#(enter your way through all the questions. The only one you will likely have to answer is regarding your Continent/Country)</pre>
<pre># tell the cpan shell to follow the dependency tree and automatically grab any required modules
o conf prerequisites_policy follow</pre>
<pre># make sure you have some of the basic tools needed to get the CPAN downloads working smoothly
install LWP MD5</pre>
<pre># install the razor pre-requisites now
install Net::Ping Net::DNS Time::HiRes Digest::SHA1 Getopt::Long File::Copy Digest::Nilsimsa URI::Escape</pre>
<pre>quit</pre>
</blockquote>
<pre># now install the actual razor software
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/razor/razor-agents-2.77.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/razor/razor-agents-2.77.tar.bz2</a></pre>
<pre>bunzip2 razor-agents-2.77.tar.bz2
tar xf razor-agents-2.77.tar
chown -R root.root razor-agents-2.77
cd razor-agents-2.77</pre>
<pre>perl Makefile.PL
make
make test
make install
cd ..</pre>
</blockquote>
<p>The Razor programs will now be installed in /usr/bin. In particular,  SpamAssassin makes use of the program called : &#8220;razor-check&#8221;</p>
<p>Last job is to create the Razor configuration files (they get put into <font face="Courier New" size="2">/etc/razor/</font>) by using these commands :</p>
<blockquote>
<pre>razor-admin -d -create -home=/etc/razor</pre>
</blockquote>
<p>If your server is going to    be busy, then I would recommend you edit the razor config file and turn down    the debugging level a bit :</p>
<blockquote>
<pre>vi /etc/razor/razor-agent.conf</pre>
<blockquote>
<pre>debuglevel=1</pre>
</blockquote>
</blockquote>
<p><strong>SPAMASSASSIN </strong></p>
<p><a href="http://www.spamassassin.org/">http://www.spamassassin.org</a></p>
<p>Description :</p>
<blockquote><p>SpamAssassin is program that scans email messages using a set of rules, and    then assigns a score. If the score is higher than your nominated limit, then    the message will be tagged as spam.</p></blockquote>
<pre># install the pre-requisite modules for spamassassin
perl -MCPAN -e shell</pre>
<blockquote>
<pre># tell the cpan shell to follow the dependency tree and automatically grab any required modules
o conf prerequisites_policy follow</pre>
<pre># make sure we have all the SpamAssassin prerequisites installed
install Digest::SHA1 HTML::Parser Storable MIME::Base64 DB_File Net::DNS Net::SMTP Mail::SPF::Query IP::Country::Fast BerkeleyDB</pre>
<pre>exit</pre>
</blockquote>
<p>Download and compile</p>
<blockquote>
<pre>wget <a href="http://apache.mirror.pacific.net.au/spamassassin/source/Mail-SpamAssassin-3.1.2.tar.gz">http://apache.mirror.pacific.net.au/spamassassin/source/Mail-SpamAssassin-3.1.2.tar.gz</a></pre>
<pre>tar xzf Mail-SpamAssassin-3.1.2.tar.gz
chown -R root.root Mail-SpamAssassin-3.1.2
cd Mail-SpamAssassin-3.1.2</pre>
<pre>perl Makefile.PL
make
make install
cd ..</pre>
</blockquote>
<p>&#8220;make install&#8221; creates the following main files :</p>
<blockquote>
<pre>/usr/bin/spamassassin            &lt;- This is the command-line version of the SpamAssassin program</pre>
<pre>/usr/bin/spamc                   &lt;- Daemonised SpamAssassin client
/usr/bin/spamd                   &lt;- Daemonised SpamAssassin server</pre>
<pre>/usr/share/spamassassin/         &lt;- The SpamAssassin logic/filter files live here
/etc/mail/spamassassin/local.cf  &lt;- sitewide configuration settings</pre>
</blockquote>
<p>Test to see if the installation was successful. (Watch the output from the  script. SpamAssassin will add headers to the message. In particular look for the  &#8220;X-Spam-Status: &#8221; and see if it correctly tags the message with a Yes or No)</p>
<blockquote>
<pre>spamassassin -t &lt; sample-nonspam.txt
spamassassin -t &lt; sample-spam.txt</pre>
</blockquote>
<p>To improve security, modify the configuration of the spamd daemon so it runs  under its own uid</p>
<blockquote><p>Create a spamd user for the spamd process to run as</p>
<blockquote>
<pre>groupadd spamd
useradd -g spamd spamd</pre>
</blockquote>
<p>Modify / create the spamd configuration file</p>
<blockquote>
<pre>vi /etc/sysconfig/spamassassin</pre>
<blockquote>
<pre># Hint : if you want to enable SpamAssassin debugging
# (the debug output goes to /var/log/maillog) then use :
# SPAMDOPTIONS="-x -u spamd -H /home/spamd -d -D"
# Don't leave debugging turned on unnecessarily though,
# because it will slow down a busy server.
#
# Otherwise, for normal operation (debugging disabled) use following combo :
# -x means not to look for any per-user preferences ( since all our users are virtual)
# -u means to run as userid spamd
# -H tells the addon apps like .razor to store all their files into eg /home/spamd/.razor
# -d tells spamd to run as a daemon
SPAMDOPTIONS="-x -u spamd -H /home/spamd -d"</pre>
</blockquote>
</blockquote>
</blockquote>
<p>Configure the spamd daemon so it is running all the time from bootup onwards</p>
<blockquote>
<pre>cp spamd/redhat-rc-script.sh /etc/rc.d/init.d/spamd
chmod 700 /etc/rc.d/init.d/spamd
cd ..</pre>
<pre>chkconfig --add spamd</pre>
<p>Then I like to use the <font face="Courier" size="2">ntsysv</font> program    to double-check that spamd is set to launch at boot time</p></blockquote>
<p>Setup the SpamAssassin configuration</p>
<blockquote>
<pre>vi /etc/mail/spamassassin/local.cf</pre>
<blockquote>
<pre># Define the sensitivity level.
required_score 5</pre>
<pre># Allow SpamAssassin to rewrite the subject line of any messages it classifies as spam
# This is the value that will prepended to the subject line of messages classified as spam
rewrite_header Subject [SPAM]</pre>
<pre># Put spam analysis reports into to the headers of the message (rather than the body)
report_safe 0</pre>
<pre># Enable SpamAssassin's RBL checking features :
# Although we have already done some RBL filtering earier in qmail's rblsmtpd program,
# it is still recommended to turn on RBL checking in SpamAssassin, as it will run
# checks against a variety of different RBL sources, and the results will help
# tag spam more accurately
skip_rbl_checks 0
# If we haven't received a response from the RBL server in X seconds, then skip that test
rbl_timeout 3</pre>
<pre># You can nominate any netblocks that you control, and contain mailservers that
# you trust. IE you control the mailservers in these netblocks so there is no
# need to be running RBL checks against these particular servers.
# You should include all the netblocks used by email clients on your local lan.
# Also make sure you include any netblocks that host your mail servers.
trusted_networks 127.0.0.1
trusted_networks 123.123.123.0/24</pre>
<pre># Enable auto-learning
use_bayes 1
bayes_auto_learn 1
# we are going to run a single global bayes db for all users ( rather than a db per user)
bayes_path /home/spamd/.spamassassin/bayes</pre>
<pre># Enable auto-whitelisting
use_auto_whitelist 1</pre>
</blockquote>
<p>Just to make sure the bayes database directory will be setup correctly :</p>
<blockquote>
<pre>mkdir /home/spamd/.spamassassin
chown -R spamd.spamd /home/spamd/.spamassassin</pre>
</blockquote>
<p>If you wish to view all the possible configuration options, use this    command :</p>
<blockquote>
<pre>perldoc Mail::SpamAssassin::Conf</pre>
</blockquote>
<p>Enable the razor functions</p>
<blockquote>
<pre>vi /etc/mail/spamassassin/v310.pre</pre>
<blockquote>
<pre>#uncomment the following line :</pre>
<pre>loadplugin Mail::SpamAssassin::Plugin::Razor2</pre>
</blockquote>
</blockquote>
</blockquote>
<p>OK, the SpamAssassin software is now fully installed!</p>
<p>Any mail that SpamAssassin classifies as spam will have [SPAM] added to the  subject line.  You should now probably setup some docs for your users  showing them how they can use message filtering rules in their email client. You  can see our message filtering guides <a href="http://www.bowe.id.au/Internet/Support/Mail/Spam/SpamAssassin/Default.htm">here</a></p>
<p>If you aren&#8217;t ready to reboot the server now, you can fire up spamd in the    mean time with this command :</p>
<blockquote>
<pre>/etc/rc.d/init.d/spamd start</pre>
</blockquote>
<p>If all goes well you will see some output like this :</p>
<blockquote>
<pre>9721 ? S 0:01 /usr/bin/spamd -x -u spamd -H /home/spamd -d</pre>
</blockquote>
<p>(Note that spam filtering isn&#8217;t actually operational on your server yet, you  need to use the qmail-scanner program to feed mail through the SpamAssassin  scripts)</p>
<p><strong>CLAM ANTI-VIRUS </strong></p>
<p><a href="http://www.clamav.net/">http://www.clamav.net</a></p>
<p>Clam antivirus can run in two different modes. Either as a normal          command line scanner, or as a client/daemon pair.</p>
<p>When working as a command line scanner, you perform your scanning using          the program &#8220;clamscan&#8221;. If a complex program like a virus scanner is run          repetitively (ie being launched for every email that passes through your          system), it chews up a lot of CPU/disk resources. To get around this          issue you can launch Clam as a daemon (clamd). This is where a copy of          Clam is launched and stays active in the background. You then do your          scanning using the clam<strong>d</strong>scan client, which is only small, thus          making it fast to launch/run. The client sends commands to the daemon,          and the daemon will take care of scanning the message and returning the          results to the client. (The same technique is used by SpamAssassin where          you can use the full spamassassin command line version, or the spamc/spamd          client/daemon pair).</p>
<p>In a busy environment, there is no doubt that the client/daemon method          is the best way to go</p>
<blockquote>
<pre>groupadd clamav
useradd -g clamav -s /bin/false -c "Clam AntiVirus" clamav</pre>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/clamav/clamav-0.88.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/clamav/clamav-0.88.tar.gz</a>
tar xzf clamav-0.88.tar.gz
chown -R root.root clamav-0.88
cd clamav-0.88
./configure
make
make install</pre>
</blockquote>
<p>Customise the clamd configuration file</p>
<blockquote>
<pre>vi /usr/local/etc/clamd.conf</pre>
<blockquote>
<pre># make sure you comment out the "example" line</pre>
<pre>LogSyslog
FixStaleSocket
User clamav</pre>
</blockquote>
</blockquote>
<p>Configure clamd so it is running all the time from bootup onwards</p>
<blockquote>
<pre>cp contrib/init/RedHat/clamd /etc/rc.d/init.d/
chmod 744 /etc/rc.d/init.d/clamd</pre>
<pre>chkconfig --add clamd</pre>
</blockquote>
<p>Then I like to use the <font face="Courier" size="2">ntsysv</font> program    to double-check that clamd is set to launch at boot time</p>
<p>If you aren&#8217;t ready to reboot the server now, you can fire up clamd    in the mean time with this command :</p>
<blockquote>
<pre>/etc/rc.d/init.d/clamd start</pre>
</blockquote>
<p>At this point the clamd software should be running. A good way to verify    this is to use this command :</p>
<blockquote>
<pre>ps axf</pre>
</blockquote>
<p>And if all is well, you should be able to see something like this :</p>
<blockquote>
<pre>18144 ? S 0:00 /usr/local/sbin/clamd</pre>
</blockquote>
<p>Setup the freshclam configuration file</p>
<blockquote>
<pre>vi /usr/local/etc/freshclam.conf</pre>
<blockquote>
<pre># make sure you comment out the "example" line
LogSyslog
DatabaseOwner clamav
DatabaseMirror db.au.clamav.net  (where "au" matches <em>your</em> country code)
NotifyClamd</pre>
</blockquote>
</blockquote>
<p>Configure freshclam to start on boot</p>
<blockquote>
<pre>vi /etc/rc.d/rc.local</pre>
<blockquote>
<pre>/usr/local/bin/freshclam -d</pre>
</blockquote>
</blockquote>
<p>Launch freshclam now</p>
<blockquote>
<pre>/usr/local/bin/freshclam -d</pre>
</blockquote>
<p>At this point the freshclam software should be running. A good way to verify    this is to use this command :</p>
<blockquote>
<pre>ps axf</pre>
</blockquote>
<p>And if all is well, you should be able to see something like this :</p>
<blockquote>
<pre>18144 ? S 0:00 /usr/local/sbin/clamd</pre>
</blockquote>
<pre></pre>
<p><strong>QMAIL-SCANNER </strong>   <img src="http://www.bowe.id.au/images/updated.gif" border="0" height="12" width="49" /></p>
<p><a href="http://qmail-scanner.sourceforge.net/"> http://qmail-scanner.sourceforge.net</a></p>
<p>Description :</p>
<blockquote><p>Qmail-Scanner is an add-on that enables a qmail server to scan    messages for certain characteristics. It is typically used for its anti-virus    protection functions, in which case it is used in conjunction with commercial    (or open source) virus scanners. It also capable of blocking email that    contains specific strings in particular headers, or particular attachment    filenames or types (e.g. *.VBS attachments).</p></blockquote>
<p>Install the required supporting modules for Qmail-Scanner</p>
<blockquote><p>TNEF unpacker</p>
<blockquote>
<pre><a href="http://sourceforge.net/projects/tnef/">http://sourceforge.net/projects/tnef/</a></pre>
<pre>cd /usr/local/src
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/tnef/tnef-1.3.4.tar.gz">http://optusnet.dl.sourceforge.net/sourceforge/tnef/tnef-1.3.4.tar.gz</a></pre>
<pre>tar xzf tnef-1.3.4.tar.gz
chown -R root.root tnef-1.3.4
cd tnef-1.3.4
./configure
make
make install
cd ..</pre>
</blockquote>
<p>ReformatMIME (from the Maildrop package)</p>
<blockquote>
<pre><a href="http://sourceforge.net/projects/courier">http://sourceforge.net/projects/courier</a></pre>
<pre>cd /usr/local/src
wget <a href="http://prdownloads.sourceforge.net/courier/maildrop-2.0.1.tar.bz2">http://optusnet.dl.sourceforge.net/sourceforge/courier/maildrop-2.0.1.tar.bz2</a></pre>
<pre>bunzip2 maildrop-2.0.1.tar.bz2
tar xf maildrop-2.0.1.tar
chown -R root.root maildrop-2.0.1.tar
cd maildrop-2.0.1
./configure
make
make install-strip
make install-man
cd ..</pre>
</blockquote>
</blockquote>
<p>A &#8220;<a href="http://toribio.apollinare.org/qmail-scanner/">Qmail-Scanner ST  patch</a>&#8221; has been released by Salvatore Toribio, which greatly extends the  functionality of qmail-scanner. The patch adds extra features to help deal with  spam (such as dropping messages that exceed a certain SpamAssassin score). We  are going to use this patch, as it makes qmail-scanner much more useful.</p>
<blockquote>
<pre>cd /usr/local/src</pre>
<pre># Grab the qmail-scanner source
wget <a href="http://optusnet.dl.sourceforge.net/sourceforge/qmail-scanner/qmail-scanner-1.25.tgz">http://optusnet.dl.sourceforge.net/sourceforge/qmail-scanner/qmail-scanner-1.25.tgz</a>
tar xzf qmail-scanner-1.25.tgz
chown -R root.root qmail-scanner-1.25</pre>
<pre># Grab and apply the qmail-scanner-st patch
wget <a href="http://toribio.apollinare.org/qmail-scanner/download/q-s-1.25st-20050406.patch.gz">http://toribio.apollinare.org/qmail-scanner/download/q-s-1.25st-20050406.patch.gz</a>
gunzip q-s-1.25st-20050406.patch.gz
patch -p0 &lt; q-s-1.25st-20050406.patch</pre>
<pre>cd qmail-scanner-1.25</pre>
</blockquote>
<p>Now at this point, I would recommend you spend some time reading the   <a href="http://qmail-scanner.sourceforge.net/">qmail-scanner documentation</a>.    And once you have read that, take a look at the   <a href="http://toribio.apollinare.org/qmail-scanner/">qmail-scanner-st patch    doco</a></p>
<p>Next, create a user and group for the qmailscanner to run under</p>
<blockquote>
<pre>groupadd qscand
useradd -c "Qmail-Scanner Account" -g qscand -s /bin/false qscand</pre>
</blockquote>
<p>For qmailscanner to work correctly with clamav, you need to adjust clamav to  run under the qscand username</p>
<blockquote>
<pre>vi /usr/local/etc/clamd.conf</pre>
<blockquote>
<pre># look for the line that says "User clamav" and replace with
User qscand</pre>
</blockquote>
<pre>/etc/rc.d/init.d/clamd restart</pre>
</blockquote>
<p>Configure Qmail-Scanner :</p>
<blockquote>
<pre># Here are the settings we used at our site for configuring Qmail-Scanner :
#
# configure Qmail-Scanner to work in the following manner :
#   - notify a nominated admin each time a virus is detected
#     (in this case it will be virusadmin@<font color="#ff0066">yourdomain.com</font>)
#   - use the client/server version of Clam AV for anti-virus scanning.
#   - enable support for spamc/spamd in "verbose" mode.
#     Qmail-Scanner can run spamd in "fast" mode or "verbose" mode.
#     You can read more about this at the <a href="http://qmail-scanner.sourceforge.net/FAQ.php">Qmail-Scanner FAQ page</a>.
#     I would recommend that you use verbose mode as this allows you to get access to
#     the full reporting/tagging features that SpamAssassin can provide. It costs you
#     a fraction more CPU power, but provides a much greater range of features.
#   - Use a medium level of sensitivity when blocking mail due to broken MIME formatting
#
#   THE COMMANDS HIGHLIGHTED IN BLUE BELOW ARE FROM THE QMAIL-SCANNER-ST PATCH
#   - sa-delete sets the point that spam mail is autodeleted.
#     <em>sa-delete</em> is a relative value to the SpamAssassin <em>required_hits</em>.
#     so in our case, the spam will be deleted at a score of 10</pre>
<pre>./configure \
  --admin virusadmin \
  --domain <font color="#ff0066">yourdomain.com</font> \
<span style="background-color:#99ccff;">  --admin-fromname "</span><font color="#ff0066"><span style="background-color:#99ccff;">yourdomain.com</span></font><span style="background-color:#99ccff;"> Postmaster" \
</span>  --local-domains "<font color="#ff0066">yourdomain.com</font>" \
  --scanners clamdscan,verbose_spamassassin \
  --fix-mime 1 \
  --debug no \
<span style="background-color:#99ccff;">  --sa-delete 5 \
  --sa-reject yes \</span>
  --install</pre>
</blockquote>
<p>Note : If the install fails with an error like this :</p>
<blockquote>
<pre><font face="Courier New" size="2"><span style="font-size:10pt;">Redhat hosts need to have perl-suidperl installed to get setuid support</span></font></pre>
<p>Then you will need to do something like this (this example for Redhat      7.3) :</p>
<pre>cd /usr/local/src
wget <a href="http://redhat.pacific.net.au/redhat/redhat-7.3-en/os/i386/RedHat/RPMS/perl-suidperl-5.6.1-34.99.6.i386.rpm">http://redhat.pacific.net.au/redhat/redhat-7.3-en/os/i386/RedHat/RPMS/perl-suidperl-5.6.1-34.99.6.i386.rpm</a>
rpm -ivh perl-suidperl-5.6.1-34.99.6.i386.rpm</pre>
</blockquote>
<p>Edit the perscanner file which is used to block mail that contains    particular strings. perlscanner is a tool that is included with qmail-scanner,    and it is executed after all the other anti-virus scanners have run (eg    clamscan). This system provides a good failsafe in case some new virus comes    along that the virus-scanner cant detect yet. perlscanner is perfect for    blocking those virus-prone attachments that have no legitimate purpose in    email.</p>
<blockquote>
<pre>vi /var/spool/qscan/quarantine-events.txt</pre>
<blockquote><p>Uncomment the following lines :</p>
<pre>.lnk SIZE=-1 LNK files not allowed per Company security policy
.wsh SIZE=-1 WSH files not allowed per Company security policy
.vbs SIZE=-1 VBS files not allowed per Company security policy
.scr SIZE=-1 SCR files not allowed per Company security policy
.hta SIZE=-1 HTA files not allowed per Company security policy
.pif SIZE=-1 PIF files not allowed per Company security policy
.cpl SIZE=-1 CPL files not allowed per Company security policy</pre>
</blockquote>
<pre># rebuild the perlscanner database
setuidgid qmaild /var/qmail/bin/qmail-scanner-queue.pl -g</pre>
</blockquote>
<p>Any SMTP sessions that are dropped (due to network outages/etc) may lead to  files lying around in /var/spool/qmailscan . Running /var/qmail/bin/qmail-scanner-queue.pl  -z at least once daily will ensure such files are deleted when they&#8217;re over 30  hours old. We will make a cronjob to do that :</p>
<blockquote>
<pre>crontab -e</pre>
<blockquote>
<pre>0 0 * * * /var/qmail/bin/qmail-scanner-queue.pl -z</pre>
</blockquote>
</blockquote>
<p>Now define what mail is to be sent through the Qmail-Scanner, also make sure that your qmail-smtpd script allocates sufficient resources to support the needs of Qmail-Scanner + Antivirus + SpamAssassin. At our site, we have configured Qmail-Scanner to virusscan all messages (ie inbound and outbound mail). We did this by setting up our our <font face="Courier New" size="2">/var/qmail/supervise/qmail-smtpd/run</font>      file like this :</p>
<blockquote>
<pre>vi /var/qmail/supervise/qmail-smtpd/run</pre>
</blockquote>
<blockquote>
<blockquote>
<pre>#!/bin/sh
<strong># when QMAILQUEUE is set, all mail will be sent to the nominated script
QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl" export QMAILQUEUE</strong>

QMAILDUID=`id -u qmaild`
NOFILESGID=`id -g qmaild`

<strong># softlimit needs to be set at something large such as 1<span>5</span>000000
# to allow virusscanning software to run successfully
</strong>exec /usr/local/bin/softlimit -m <strong>1<span>5</span>000000</strong> \
 /usr/local/bin/tcpserver \
  -v -x /etc/tcp.smtp.cdb \
  -c 20 -R -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
... and the rest of the file snipped ...</pre>
</blockquote>
<p>Restart the qmail-smtpd service :</p>
<blockquote>
<pre>svc -d /service/qmail-smtpd
svc -u /service/qmail-smtpd</pre>
</blockquote>
<p>However, if you don&#8217;t want to virusscan all mail, you can selectively nominate      which IP ranges should or shouldn&#8217;t be checked by setting the QMAILQUEUE variable      via your /etc/tcp.smtp file rather than inside the supervise/qmail-smtpd/run      file. Refer to the Qmail-Scanner home page for setup examples.</p></blockquote>
<p><strong>QMAIL-SCANNER / SPAMASSASSIN NOTES :</strong></p>
<blockquote><p>How can I tell if SpamAssassin is working?</p>
<blockquote><p>Each time SpamAssassin processes a message, it will log some information      to /var/log/maillog (score, message size, time taken to process)</p></blockquote>
<p>Not all mail gets passed through SpamAssassin</p>
<blockquote><p>We have configured our <font face="Courier New" size="2">supervise/qmail-smtpd/run</font>      script so that it runs Qmail-Scanner for every mail message. This means all      incoming and outgoing mail will get virus-checked. However this doesn&#8217;t      necessarily mean that every message passing through Qmail-Scanner will also      get sent through SpamAssassin.</p>
<p>Qmail-Scanner has been coded so that messages are only passed onto      SpamAssassin if the RELAYCLIENT variable from tcp.smtp is not set. The      idea behind this to reduce load on the system by not running SpamAssassin on mail      originated by your users.</p>
<p>It is possible to force SpamAssassin checking for local users if you      choose by setting QS_SPAMASSASSIN=&#8221;on&#8221; for the appropriate entries      in your tcp.smtp file</p>
<p>You can read more about this subject at the     <a href="http://qmail-scanner.sourceforge.net/FAQ.php">Qmail-Scanner FAQ      page</a></p></blockquote>
<p>Is it possible to configure per-user settings for SpamAssassin?</p>
<blockquote><p>It depends on your configuration. We believe it will be possible to      implement an interface so that vpopmail users can turn SpamAssassin checking      on/off, and also set their own custom required_hits. We are hoping to store      these settings as additional columns in the vpopmail MySQL database&#8230; Stay      tuned and we will post more info as it comes to hand</p></blockquote>
<p>Can I make it so that all      the spam get sent to my a SPAM or TRASH folder?</p>
<blockquote><p><a href="http://www.bowe.id.au/michael/isp/send-spam-to-folder.htm">Yes, have a look at this example</a>,      or take a look at the $smaildir option in the qmail-scanner-st patch</p></blockquote>
<p>Qmail-scanner&#8217;s quarantine directory</p>
<blockquote><p>Each virus infect mail message gets quarantines into the following      directory :</p>
<blockquote>
<pre>/var/spool/qmailscan/quarantine/new</pre>
</blockquote>
<p>So you will need to periodically purge the files from that dir, or else      your hard disk will eventually fill up!</p>
<p>eg setup a crontab entry like this :</p>
<blockquote>
<pre>0 * * * * find /var/spool/qmailscan/quarantine/new -type f -mtime +30 -exec rm '{}' \;</pre>
</blockquote>
</blockquote>
</blockquote>
<hr />
<h3><a name="TIPS"></a>TIPS &amp; MISC NOTES :</h3>
<p>&#8220;ps axf&#8221; is your friend. Particularly useful for visualising how the    supervise/qmail processes all fit together.<br />
&#8220;ps axfu&#8221; is good for double checking what accounts that individual server    processes are running under<br />
<hr />
<h3><a name="Example_scripts"></a>SOME EXAMPLE MAILBOX MANAGEMENT SCRIPTS  :</h3>
<p>Since all the information for your email domains and mailboxes are store in  MySQL, it is easy to create scripts so your support staff can quickly navigate /  view all this account information.</p>
<p>Our support staff&#8217;s intranet site is a Windows 2000 machine running IIS5 with  ASP. Here is a couple of example ASP scripts that I hacked together that show  what can be achieved : <a href="http://www.bowe.id.au/michael/isp/webmail-server-scripts/vpopmail-asp-scripts.v120.zip"> vpopmail-asp-scripts.v120.zip</a>.. No doubt it would be easy enough though to  use these same techniques in PHP if you are running linux/apache for your  intranet</p>
<p>The script &#8220;viewvlogs&#8221; allows you to view browse through the vpopmail &#8220;vlog&#8221;  table in MySQL to look for people who have failed to auth successfully when  trying to check mail.</p>
<p>The script &#8220;viewpop3&#8243; allows you to see a list of email domains hosted on  your server. You can do things like view all users from a domain, or view an  individual mailbox. The output will show useful things like clear passwords,  mailbox size. Also there are buttons that will log you into qmailadmin or  SquirrelMail as a given user using just a single mouse click</p>
<p>Some screenshots of viewpop3 script:</p>
<blockquote><p><a href="http://www.bowe.id.au/michael/isp/webmail-server-scripts/viewpop3-mainscreen.gif">Main login screen</a><br />
<a href="http://www.bowe.id.au/michael/isp/webmail-server-scripts/viewpop3-show-domaindropdown.gif">Login to a    domain</a>, <a href="http://www.bowe.id.au/michael/isp/webmail-server-scripts/viewpop3-show-domain.gif">View all    mailboxes on a domain</a><br />
<a href="http://www.bowe.id.au/michael/isp/webmail-server-scripts/viewpop3-choose-emailaddress.gif">Login to an    email address</a>, <a href="http://www.bowe.id.au/michael/isp/webmail-server-scripts/viewpop3-viewmailbox.gif">   View details for email address</a></p></blockquote>
<p>One final note, if you are running IIS, you need to download and install the <a href="http://www.mysql.com/downloads/api-myodbc-3.51.html">MySQL Connector  ODBC &#8220;Windows Driver Installer&#8221;</a> files onto your server to allows these  ASP scripts to work.</p>
<p><a name="CREATE_MAILBOX_VIA_SQL"></a>On a related subject, have you ever wanted to be able to create mailboxes  &#8220;on-the-fly&#8221; via a webpage or similar? Well if you are running the MySQL  back-end, then you are in luck! It is possible to use an INSERT command to  create the new user in the MySQL. When the user 1st POP/IMAP&#8217;s into their  account, or when they first receive a message, their mailbox will automatically  be created on the hard disk of the mail server. I have an example showing how I  create mailboxes on-the-fly from an IIS server using an ASP script <a href="http://www.bowe.id.au/michael/isp/webmail-server-scripts/asp-vpopmail-passwd-entries.txt">asp-vpopmail-passwd-entries.txt</a>.  ( And here is another link that shows how you can <a href="http://www.bowe.id.au/michael/isp/webmail-server-scripts/php-password-encrypt.htm">generate suitably  encrypted passwords using PHP</a> ). And there is some more spirited discussion  on this subject here <a href="http://www.mail-archive.com/qmailadmin@inter7.com/msg03509.html"> http://www.mail-archive.com/qmailadmin@inter7.com/msg03509.html</a></p>
<hr />
<h3><a name="TODO"></a>TODO :</h3>
<ul>
<li>Use netqmail-1.05</li>
<li>Update to MySQL v4.x</li>
<li>Use Fedora rather than Redhat</li>
</ul>
<p>Other misc ramblings :</p>
<p>I sold the ISP that I used to own to a larger national provider, and now &#8220;I  work for them&#8221;. At this larger company we use <a href="http://www.postfix.org/"> Postfix</a> (and <a href="http://www.ijs.si/software/amavisd/">amavisd</a>/spamassassin/clamd)  rather than qmail (and qmail-scanner/spamd/clamd). After learning Postfix I can  confidently say that it is a much superior MTA to qmail. However even the most  pro-Postfix staff are amazed at the ease of use of the vpopmail/qmail system.  Although Postfix also has virtual mailbox support, there is no easy-to-use  package like vpopmail for driving this system. Since I now spend my days working  with Postfix, my development of this webpage has slowed somewhat. Hopefully I  will be able to find the time to keep this page fairly up to date  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />    <img src="http://www.bowe.id.au/images/new.gif" border="0" height="12" width="31" /> <a href="http://www.bowe.id.au/michael/isp/postfix-server.htm">I  have published a Postfix server guide</a></p>
<hr />
<h3> <a href="http://www.amazon.com/exec/obidos/registry/33WG1KVR6YTI7/102-0564362-0164105"> I have an Amazon wish list</a></h3>
<p>A big thank you to these people who have sent me a gift :</p>
<ul>
<li>Dave Richardson</li>
<li>Ken Winke</li>
<li>Joseph Schmitt II</li>
<li>Oban Lambie</li>
<li>Andrew Seely</li>
<li>Marco Varanda</li>
<li>Raymond Luong</li>
<li>Mansung Nojima</li>
<li>Charlie</li>
<li>Andrew Harteveldt</li>
<li>Nick Strupp</li>
<li>Carol Blevins</li>
<li>Marc van de Geijn</li>
</ul>
<hr />
<p align="right"><a href="http://www.bowe.id.au/michael/isp/default.htm">Back to Michael&#8217;s ISP Links page</a></p>
<p> <!--webbot bot="HitCounter" u-custom i-image="0" i-resetvalue="284055" PREVIEW="&lt;strong&gt;[Hit Counter]&lt;/strong&gt;" i-digits="7" startspan --><img src="http://www.bowe.id.au/_vti_bin/fpcount.exe/?Page=michael/isp/webmail-server.htm%7CImage=0%7CDigits=7" alt="Hit Counter" /><!--webbot bot="HitCounter" i-checksum="54697" endspan -->&lt;!&#8211;<img src="/scripts/counter/counter.exe?link=webmail-server&amp;style=odometer">&#8211;&gt;</p>
<p>Last updated :  <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d-%b-%Y" startspan -->15-May-2007<!--webbot bot="Timestamp" i-checksum="16019" endspan --><br />
<strong> <a href="mailto:mbowe@pipeline.com.au"><font size="4">Please send me your feedback!</font></a><font size="4"> </font></strong></p>
<hr />
<p align="center"><!-- google_ad_client = "pub-4778638820405329"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text"; google_ad_channel =""; google_color_border = "336699"; google_color_bg = "FFFFFF"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "008000"; //-->  </p>
<hr />
<h3><a name="CHANGELOG"></a>ChangeLog :</h3>
<p>15th May 2007 :</p>
<ul>
<li>No further changes will be made to this guide. See the text at the top  	of the document for more info.</li>
</ul>
<p>13th September 2006 :</p>
<ul>
<li>Updated the URL of the page to new site.</li>
<li>I have an updated version of this guide probably 90% written &#8211; based on    CentOS / Fedora with RPM installs of many apps&#8230; Let me know if you are    interested in seeing it !</li>
</ul>
<p>13th June 2006 :</p>
<ul>
<li>Updated the SpamAssassin v3.1.2</li>
<li>For safety sake, added a mkdir/chown for /home/spamd/.spamassassin dir    (Thanks to Steven Looi for the tip)</li>
<li>Updated to Courier-IMAP v4.1.1</li>
<li>Added a note about FAM to the Courier-IMAP section.</li>
</ul>
<p>19th March 2006 :</p>
<ul>
<li><a href="http://www.bowe.id.au/michael/isp/postfix-server.htm">My new Postfix server guide has been released</a></li>
</ul>
<p>29th March 2006 :</p>
<ul>
<li>Added info about autorespond-2.0.5</li>
<li>Updated to Courier-Authlib v0.58</li>
<li>Updated to Courier-IMAP v4.1.0</li>
<li>Updated to SqWebMail v5.1.1</li>
<li>Updated to SpamAssassin v3.1.1</li>
<li>Updated to ClamAV 0.88</li>
<li>Have been madly working on Postfix/MySQL guide. Should be ready for    publication soon. So far its a 140Kb, 2875-line monster html doc!</li>
</ul>
<p>7th November 2005</p>
<ul>
<li>Updated to SpamAssassin v3.1.0</li>
<li>Updated qmail-scanner, and added qmail-scanner-st patch</li>
</ul>
<p>27th Sep 2005</p>
<ul>
<li>Upgraded to vpopmail-5.4.10, qmailadmin-1.2.9, Courier-Authlib-0.57,    Courier-IMAP-4.0.6, ClamAV-0.87</li>
<li>Added some SqWebMail installation notes</li>
<li>Added a note on SpamAssassin 3.1</li>
<li>Added Carol Blevins to the list of people who have sent me a gift <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
</ul>
<p>15th Sep 2005</p>
<ul>
<li>Increased the POP3d softlimit from 4000000 to 6000000, after James Ecker    reported to me that 4000000 wasn&#8217;t sufficient when using Fedora/MySQL 4.1</li>
</ul>
<p>1st Sep 2005</p>
<ul>
<li>Added a ChangeLog  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li>Updated SpamAssassin hyperlink from v303 to v304</li>
<li>Added a hyperlink for Razor download</li>
<li>Added note to see if anyone would be interested to see my Postfix    equivalent to this guide</li>
</ul>
<p>   _uacct = &#8220;UA-898065-1&#8243;; urchinTracker(); </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duynam.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duynam.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duynam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duynam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duynam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duynam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/duynam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/duynam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/duynam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/duynam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duynam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duynam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duynam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duynam.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duynam.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duynam.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=duynam.wordpress.com&amp;blog=1451871&amp;post=8&amp;subd=duynam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://duynam.wordpress.com/2007/08/13/qmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/30af098ae1325ecf0a6301bafc3a5f10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duynam</media:title>
		</media:content>

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/undercon.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/updated.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/images/new.gif" medium="image" />

		<media:content url="http://www.bowe.id.au/_vti_bin/fpcount.exe/?Page=michael/isp/webmail-server.htm%7CImage=0%7CDigits=7" medium="image">
			<media:title type="html">Hit Counter</media:title>
		</media:content>

		<media:content url="/scripts/counter/counter.exe?link=webmail-server&#38;style=odometer" medium="image" />
	</item>
		<item>
		<title>10 nguyên tắc cho một website thương mại thành công</title>
		<link>http://duynam.wordpress.com/2007/08/13/10-nguyen-t%e1%ba%afc-cho-m%e1%bb%99t-website-th%c6%b0%c6%a1ng-m%e1%ba%a1i-thanh-cong/</link>
		<comments>http://duynam.wordpress.com/2007/08/13/10-nguyen-t%e1%ba%afc-cho-m%e1%bb%99t-website-th%c6%b0%c6%a1ng-m%e1%ba%a1i-thanh-cong/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 16:40:22 +0000</pubDate>
		<dc:creator>duynam</dc:creator>
				<category><![CDATA[Website-Ecomerce]]></category>

		<guid isPermaLink="false">http://duynam.wordpress.com/2007/08/13/10-nguyen-t%e1%ba%afc-cho-m%e1%bb%99t-website-th%c6%b0%c6%a1ng-m%e1%ba%a1i-thanh-cong/</guid>
		<description><![CDATA[Thương mại điện tử đã phát triển khác xa 10 năm trước và hiện nay, tính ứng dụng luôn được đặt lên hàng đầu. Sự nổi tiếng của một website đôi khi lại nhờ những yếu tố tưởng như rất nhỏ nhặt. Ảnh: Larta. 1. Thông báo người sử dụng đang ở đâu Bất cứ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=duynam.wordpress.com&amp;blog=1451871&amp;post=7&amp;subd=duynam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Thương mại điện tử đã phát triển khác xa 10 năm trước và hiện nay, tính ứng dụng luôn được đặt lên hàng đầu. Sự nổi tiếng của một website đôi khi lại nhờ những yếu tố tưởng như rất nhỏ nhặt.</p>
<p><img src="http://www.vnexpress.net/Vietnam/Vi-tinh/2007/05/3B9F5C83/web2.jpg" border="0" /><br />
Ảnh: Larta.</p>
<p>1. Thông báo người sử dụng đang ở đâu</p>
<p>Bất cứ khi nào người dùng truy cập đến một gian hàng, website cần hiển thị vị trí của họ trong cấu trúc chung của site, chẳng hạn Home &gt; Category &gt; Sub-cat &gt; Product.</p>
<p>2. Phân loại đa dạng</p>
<p>Website phải cung cấp đủ các chuẩn phân loại như &#8220;Giá cả&#8221; (Từ cao đến thấp, Từ thấp đến cao), &#8220;Tính phổ biến&#8221; (Bán chạy nhất, Được người dùng đánh giá cao nhất&#8230;), &#8220;Tính năng&#8221;, &#8220;Màu sắc&#8221;, &#8220;Kích cỡ&#8221;, &#8220;Sản phẩm mới&#8221; để khách hàng thỏa sức lựa chọn theo tiêu chí của riêng họ mà không gặp khó khăn.</p>
<p>3. Hiển thị tất cả sản phẩm cùng loại trên một trang</p>
<p>Trừ khi số sản phẩm lên tới hơn 200, website nên tạo điều kiện cho người sử dụng quan sát tổng thể các mặt hàng để họ dễ đối chiếu. Điều này cũng không khó thực hiện nhờ sự phổ biến của băng thông rộng hiện nay.</p>
<p>4. Càng chi tiết càng tốt</p>
<p>Một website sẽ được đánh giá cao nếu cung cấp một vài thông tin ấn tượng trước khi khách hàng bấm vào trang riêng về sản phẩm đó.</p>
<p>5. Chia sẻ thông tin có ích</p>
<p>Nhiều người sử dụng cho biết họ đã thấy rất nhiều mẫu quần áo đẹp, phù hợp &#8220;gu&#8221; thẩm mỹ của họ nhưng lại không biết bộ đồ đó có vừa với số đo của mình hay không. Hay không ít website kinh doanh cặp laptop &#8220;quên&#8221; thông báo chiếc cặp đó phù hợp cho máy tính xách tay 14 inch, 15 inch hay 17 inch&#8230;</p>
<p>5. Đặt thanh tìm kiếm ở vị trí dễ thấy</p>
<p>Ngay cả khi thực hiện xong lệnh search, website vẫn nên đặt thanh tìm kiếm ở vị trí trung tâm và giữ lại từ khóa cũ trong trường hợp người sử dụng muốn điều chỉnh lệnh để đạt kết quả phù hợp hơn. Bên cạnh đó, hệ thống tìm kiếm nâng cao theo giá cả, màu sắc, kích cỡ&#8230; sẽ không bao giờ thừa với khách hàng. (Người dùng vẫn xếp &#8220;tìm kiếm&#8221; là tính năng khó chịu nhất trên các website thương mại điện tử).</p>
<p>6. &#8220;Khoe&#8221; tối đa kho hàng của bạn</p>
<p><img src="http://www.vnexpress.net/Vietnam/Vi-tinh/2007/05/3B9F5C83/web.jpg" border="0" /><br />
eBay mở rộng kết quả tìm kiếm bằng cách loại bỏ bớt từ khóa. Ảnh chụp màn hình.</p>
<p>eBay đã rất thông minh trong việc hiển thị sản phẩm mà họ có dựa trên lệnh tìm kiếm của khách hàng. Chỉ một chi tiết nhỏ thôi cũng góp phần thúc đẩy công việc kinh doanh của chủ nhân một gian hàng trực tuyến.</p>
<p>7. Thông báo ngay nếu hết hàng</p>
<p>Người sử dụng sẽ khó chịu nếu họ dành cả tiếng đồng hồ ngắm nghía sản phẩm nhưng mãi đến khi bấm chọn nó thì mới phát hiện ra rằng mặt hàng đó không còn trong kho.</p>
<p>8. Trực quan sinh động</p>
<p>Do không thể cảm nhận sản phẩm như trong đời thực, ảnh, video và những lời nhận xét là thông tin vô giá với khách hàng. Một bức ảnh ở một góc chụp duy nhất không thể đủ thuyết phục người mua.</p>
<p>9. Các cách chuyển hàng</p>
<p>Website nên liệt kê các phương pháp thanh toán và phân phối hàng hóa để người sử dụng xem có phù hợp với hoàn cảnh của họ không trước khi bắt đầu mua sắm.</p>
<p>10. Khẳng định giao dịch qua e-mail</p>
<p>Một khách hàng của Dell cho hay anh ta rất lo lắng không hiểu chiếc laptop mình đặt mua có được chuyển đến trước chuyến du lịch Trung Quốc không bởi anh không muốn dành 28 giờ trên máy bay mà thiếu máy tính. Rất may, e-mail khẳng định thời hạn giao hàng của Dell đã giúp anh bình tâm.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duynam.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duynam.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duynam.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duynam.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duynam.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duynam.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/duynam.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/duynam.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/duynam.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/duynam.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duynam.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duynam.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duynam.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duynam.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duynam.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duynam.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=duynam.wordpress.com&amp;blog=1451871&amp;post=7&amp;subd=duynam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://duynam.wordpress.com/2007/08/13/10-nguyen-t%e1%ba%afc-cho-m%e1%bb%99t-website-th%c6%b0%c6%a1ng-m%e1%ba%a1i-thanh-cong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/30af098ae1325ecf0a6301bafc3a5f10?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">duynam</media:title>
		</media:content>

		<media:content url="http://www.vnexpress.net/Vietnam/Vi-tinh/2007/05/3B9F5C83/web2.jpg" medium="image" />

		<media:content url="http://www.vnexpress.net/Vietnam/Vi-tinh/2007/05/3B9F5C83/web.jpg" medium="image" />
	</item>
	</channel>
</rss>
