Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'anyway.': 0.05; 'subject:Python': 0.06; 'matches': 0.07; 'filter,': 0.09; 'rejected': 0.09; 'subject:script': 0.09; 'thrown': 0.09; 'python': 0.11; '23,': 0.16; 'blocked': 0.16; 'commandline': 0.16; 'folder.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'guess.': 0.16; 'helo': 0.16; 'normal,': 0.16; 'queuing': 0.16; 'rejected.': 0.16; 'subject:mails': 0.16; 'targets': 0.16; 'think.': 0.16; "week's": 0.16; 'wrote:': 0.18; '(not': 0.18; 'looked': 0.18; 'minutes.': 0.22; 'rules': 0.22; 'sender,': 0.22; 'instance,': 0.24; 'tend': 0.24; 'fairly': 0.24; "i've": 0.25; 'least': 0.26; 'primary': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'michael': 0.29; 'am,': 0.29; 'topic': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'usually': 0.31; 'are.': 0.31; 'factor': 0.31; 'fault': 0.31; 'though.': 0.31; 'up:': 0.31; 'checked': 0.32; 'run': 0.32; 'basic': 0.35; "can't": 0.35; 'connection': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'false': 0.36; 'smtp': 0.36; 'subject:Simple': 0.36; 'next': 0.36; "didn't": 0.36; 'subject:?': 0.36; 'too': 0.37; 'server': 0.38; 'checks': 0.38; 'stopped': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'previous': 0.38; 'anything': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'address.': 0.39; 'users': 0.40; 'how': 0.40; 'ensure': 0.60; 'even': 0.60; 'failures': 0.60; 'logged': 0.60; 'logs': 0.60; 'temporarily': 0.60; 'truly': 0.60; 'black': 0.61; 'entire': 0.61; 'simple': 0.61; 'first': 0.61; 'address': 0.63; 'name': 0.63; 'our': 0.64; 'accounts': 0.64; 'account': 0.65; 'success,': 0.65; 'six': 0.68; 'reverse': 0.68; 'watching': 0.68; 'home': 0.69; 'jul': 0.74; 'counts': 0.83; '(dns)': 0.84; '(message': 0.84; '228': 0.84; 'checks.': 0.84; 'countries,': 0.84; 'worth,': 0.84; 'average': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=hrnNLKMvA8Cz5hdmGbAS5KDq4FnV7CApbDwUsQamoi4=; b=kuq5s/B9gxuVXuVuZRpzsKhehiuPC64nvcLhqBkPn76OofwxDjgkdvn7kfomNL3x4s 30FUcllmB7Si19otouC13TbM9fUp+ItRckabqCGcmB9lqsopAkhy/WE3UhAOGpuf0wrF Tumq9bGHlns8LXaWbXYv4fADuDmkzzy9l1Ln4Wk9jVz31xefv3C7V51ze436B4N+Icr6 0Cc81smLVOxV11ZKwWnhQKOvGCoH08uI0UqWuMylKOeJyki5GIo+4QFxkIdnxPsmzLRE 18HE5suN/8jPpop+0prQbpUp9qfxKeqKO2Xcjo246/juHeTYxrZ9YKsj9BCL/DIp7BAO I08Q== MIME-Version: 1.0 X-Received: by 10.52.34.40 with SMTP id w8mr7999977vdi.7.1374509542168; Mon, 22 Jul 2013 09:12:22 -0700 (PDT) In-Reply-To: <51ED3FCE.3090506@gmail.com> References: <51ED3FCE.3090506@gmail.com> Date: Tue, 23 Jul 2013 02:12:22 +1000 Subject: Re: Simple Python script as SMTP server for outgoing e-mails? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374509551 news.xs4all.nl 15876 [2001:888:2000:d::a6]:44100 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51050 On Tue, Jul 23, 2013 at 12:21 AM, Michael Torrie wrote: > My mail server did a number of things: > 1. ensure IP address of sending server has a reverse name (domain didn't > particularly matter) > 2. ensure the HELO address in SMTP matches IP address of sending server > 3. check sender IP address against spam blacklists, which includes > netblocks of home ISPs, some entire countries, flagged subnets > 4. greylist sender IP if the recipient requested it. First connection > always fails with a nonfatal server error, next connection must wait at > least 5 minutes. If a reconnection happened too quickly, the IP was > temporarily black listed. After success, IP address is whitelisted for > a time. A commandline MTA will not be able to get through greylisting; > only a mail server with queuing could. Spambots tend to give up on the > first error, even now. Cheaper targets I guess. > 5. spamassassin checked SPF (DNS) and domainkeys (message itself) and > weighted the spam factor accordingly > > I think there were other basic rules that sendmail applied to the > sender, but I can't remember all of what they are. This is well and > truly off topic now for the python list, though. And yet off-topic does happen... For what it's worth, here's how my server is set up: 1. A variety of protocol-level checks. If you don't say HELO, for instance, you get rejected. Surprisingly, these simple checks actually keep out a lot of spam - but I've yet to see any legiit mail blocked by them. (Not that I keep logs of these any more. I stopped watching after it looked clean for a while.) And if legit mail is rejected, it'll be resent or bounced by the sending MTA anyway. 2. SPF checks on the MAIL FROM:<> address. Again, if legit mail gets rejected (which would be the fault of the sending domain owner), the server at the previous hop will deal with it. Only hard failures get thrown out; anything else just gets marked (which we usually ignore) and delivered as normal, not even spam-scored. 3. Bayesian spam filter, set very conservatively so we get false negatives but (almost) no false positives. Any spam that gets through these three checks gets delivered, and then the users will drop it in their junk folder. Every week I do a train-and-wipe run across all junk folders, which logs spam counts from our primary mailboxes. Last week's run was 228 spam across the six logged accounts (some of those accounts collect from many addresses), or an average of five false negatives per account per day, and false positives are almost completely unheard-of. Considering how much spam assaults the outside of my fortress's walls, that's a fairly good ratio, I think. SPF for the win. ChrisA