<?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/"
	>

<channel>
	<title>subprocess &#187; How To</title>
	<atom:link href="http://subprocess.net/category/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://subprocess.net</link>
	<description>linux geek/dad</description>
	<lastBuildDate>Wed, 28 Apr 2010 15:12:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Outbound SMTP Management</title>
		<link>http://subprocess.net/2008/03/08/outbound-smtp-management/</link>
		<comments>http://subprocess.net/2008/03/08/outbound-smtp-management/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 18:53:28 +0000</pubDate>
		<dc:creator>thepet</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[geek]]></category>

		<guid isPermaLink="false">http://subprocess.net/2008/03/08/outbound-smtp-management/</guid>
		<description><![CDATA[Just about all Linux server distributions install a sendmail daemon that listens on 127.0.0.1 and relays email for the localhost.  This is all fine and dandy if you have a handful of Linux servers, but can turn in to chaos once you get 30+ Linux servers.

Certain system tasks rely on getting emails to someone [...]]]></description>
			<content:encoded><![CDATA[<p>Just about all Linux server distributions install a sendmail daemon that listens on 127.0.0.1 and relays email for the localhost.  This is all fine and dandy if you have a handful of Linux servers, but can turn in to chaos once you get 30+ Linux servers.<br />
<span id="more-10"></span></p>
<p>Certain system tasks rely on getting emails to someone important.  By default there are crons that run that when they need attention they email root@localhost.  If all of these emails go to a local mbox for the root user then you&#8217;re probably missing some important emails.</p>
<p>If all systems are sending email to the internet, then you have 30+ email queues to monitor with bounces to yahoo and aol (<em><strong>Why</strong></em> are there so many emails in every email queue that are @yahoo or @aol?) filling them all up.   Also, if you want to scan all email generated from your networks for spam/viruses (just to be sure you&#8217;re not spreading something) then you have to set that up on all 30+ servers.</p>
<p>To make all this easier, use sendmail&#8217;s smarthost option.  But first you need an outgoing mail hub.  I much prefer qmail when it comes to administering and running an SMTP queue.  So I suggest you find a good candidate to be your outgoing mail hub and follow the instructions on <a href="http://www.lifewithqmail.org/" target="_blank">Life with qmail</a>.  After you get that up and running you&#8217;ll have to do a couple extra things.</p>
<p>First, set up your /etc/tcp.smtp appropriately for relaying from your network.  I&#8217;ve got  it set here to allow connections, allow relays, don&#8217;t do RBL checks, and do scan for spam/viruses for the internal network.  But, straight up deny all access from other networks:</p>
<p>127.:allow,RELAYCLIENT=&#8221;",RBLSMTPD=&#8221;",QMAILQUEUE=&#8221;/var/qmail/bin/qmail-queue&#8221;<br />
10.10.:allow,RELAYCLIENT=&#8221;",RBLSMTPD=&#8221;",QMAILQUEUE=&#8221;/var/qmail/bin/qmail-scanner-queue.pl&#8221;<br />
:deny</p>
<p>Once you have tcp.smtp set right, run &#8220;qmailctl cdb&#8221;.  Now one more thing, if your domain&#8217;s internal mail server is on the local network, make sure that this outbound mail hub gets a proper internal IP for your own domains mail server.  I had an environment once that had a screwy dns design and I&#8217;d sometimes get an internal IP for it and other times an external IP.  If you can&#8217;t get the dns set right, add an entry to /var/qmail/control/smtproutes:</p>
<p>yourdomain.com:10.10.0.10<br />
.yourdomain.com:10.10.0.10</p>
<p>Where yourdomain.com is the domain after the @ for local deliveries and the 10.10.0.10 ip is the internal IP of your internal email server.</p>
<p>Now, for all your other servers.</p>
<p>Edit your /etc/mail/sendmail.mc file and look for a section like this:</p>
<p>dnl # Uncomment and edit the following line if your outgoing mail needs to<br />
dnl # be sent out through an external mail server:<br />
dnl #<br />
dnl define(`SMART_HOST&#8217;,`smtp.your.provider&#8217;)</p>
<p>Uncomment  that line so it looks like:</p>
<p>define(`SMART_HOST&#8217;, `outboundsmtp.yourdomain.com&#8217;);</p>
<p>Obviously you&#8217;ll set outboundsmtp.yourdomain.com to the host name of your &#8220;outgoing mail hub&#8221;.  Once you have that set, compile your new sendmail config with &#8220;make -C /etc/mail&#8221;.</p>
<p>And finally, edit the /etc/mail/aliases file to make sure that all system emails go to someone real.  By default it all gets funneled to the &#8220;root&#8221; user.  So set an alias for &#8220;root&#8221; to go to &#8220;it@yourdomain.com&#8221; or whatever is appropriate.  After editing aliases you&#8217;ll need to run &#8220;newaliases&#8221;.</p>
<p>Got some windows servers in the mix?  No problem, IIS can create an SMTP service on localhost.  Set relay restrictions to only allow email from 127.0.0.1 and  set the <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/6003ab51-7eb5-47b2-8d92-e26b1deeeac1.mspx?mfr=true" target="_blank">smarthost to your new mail hub</a>.</p>
<p>Now you need to get monitoring in place.  Nagios is pretty common, so I&#8217;ll go that route.  There&#8217;s already a nagios plugin for sendmail.  On each and every one of your 30+ Linux servers configure nagios to monitor for the sendmail process and that the email queue is small.  I suggest warn at 5 emails in the queue, alert at 10.  The queue should actually almost always be empty.</p>
<p>For your qmail outgoing mail hub you&#8217;ll want some extra monitoring.  I suggest you monitor for the qmail procs, spamassassin, your virus scanner, disk space for your qmail queue (<a href="http://qmail.jms1.net/scripts/qfixq.shtml" target="_blank">you do <strong>NOT</strong> want the headache involved with a corrupted qmail queue because you didn&#8217;t realize disk space was tight</a>), and of course the size of the queue.  There are already written <a href="http://www.openfusion.com.au/labs/nagios/check_qmailq" target="_blank">nagios scripts</a> for this.  You&#8217;ll have to experiment with the warn/alert levels.  You want to accommodate for surges in email activity but still get alerted if something is actually wrong.  Don&#8217;t set it too low and get numb to the noise from email surges. Don&#8217;t set it so high that you won&#8217;t be notified of an issue until it&#8217;s been far too long.  There is no magic number so you&#8217;ll have to experiment.</p>
<p>Next is documentation.  Update your documentation for creating a new server so that you and whoever else may create one remembers to properly configure the email system.</p>
<p>Also, make sure all software developers are aware that if they want to send email from their apps that they should use localhost as an SMTP server or use the &#8220;/usr/sbin/sendmail&#8221; on the localhost.  Applications almost never have full mail queue features, meaning a temporary delivery failure would result in a lost email.  If the app is able to attempt to send an email then more than likely the sendmail daemon on localhost will be able to accept delivery of that message.  Especially since you have it properly monitored.  And sendmail is a fully functioning mail queue with retries and proper logging.</p>
<p>So hopefully all of this will reduce the number of smtp queues you need to worry about.  And also keep the system chatter emails off the localhosts and get them to your inbox.  Some distributions install very noisy crons that send useless email noise though, don&#8217;t be afraid to tell them to shut it.  It&#8217;s good though, reduce the noise and increase the signal.  Even if it may be more work up front, it&#8217;s worth it in the long run.</p>
]]></content:encoded>
			<wfw:commentRss>http://subprocess.net/2008/03/08/outbound-smtp-management/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
