Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed0.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!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.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.06; 'deny': 0.07; 'failing': 0.07; 'permitted': 0.07; 'strict': 0.07; 'tries': 0.07; 'booth': 0.09; 'check,': 0.09; 'omit': 0.09; 'pretend': 0.09; 'rejected': 0.09; 'subject:script': 0.09; 'thrown': 0.09; 'random': 0.14; '"is': 0.16; '23,': 0.16; 'address).': 0.16; 'ah,': 0.16; 'earlier.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'rejected.': 0.16; 'subject:mails': 0.16; 'unchanged': 0.16; 'validation.': 0.16; 'wrote:': 0.18; 'cheap': 0.19; 'server,': 0.19; '(the': 0.22; 'command': 0.22; '>>>': 0.22; "shouldn't": 0.24; 'handling': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'point': 0.28; 'appear': 0.29; 'correct': 0.29; 'michael': 0.29; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:wiki': 0.31; 'usually': 0.31; '>>>>': 0.31; 'commonly': 0.31; 'correctly.': 0.31; 'servers.': 0.31; 'spam,': 0.31; 'url:wikipedia': 0.31; 'anyone': 0.31; 'checked': 0.32; 'addresses': 0.33; 'checking': 0.33; 'could': 0.34; 'common': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'there': 0.35; 'smtp': 0.36; 'subject:Simple': 0.36; "didn't": 0.36; 'thanks': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'being': 0.38; 'server': 0.38; 'problems': 0.38; 'checks': 0.38; 'gmail': 0.38; 'others.': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'legitimate': 0.39; 'reported': 0.39; 'use.': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'guy': 0.60; 'most': 0.60; 'simply': 0.61; 'simple': 0.61; 'you.': 0.62; 'complete': 0.62; 'address': 0.63; 'chance': 0.65; 'forward': 0.65; 'great': 0.65; 'situation': 0.65; 'yes': 0.68; 'anything.': 0.68; 'invalid': 0.68; 'nobody': 0.68; 'mail.': 0.69; 'records,': 0.69; 'receive': 0.70; 'internet': 0.71; 'therefore': 0.72; 'businesses': 0.72; 'records': 0.73; 'jul': 0.74; 'inbox.': 0.78; 'detecting': 0.84; 'transmitting': 0.84; 'address;': 0.91; 'bounces': 0.91; "sender's": 0.91; 'inbox': 0.93; 'yours.': 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=B0MLorncoH1spqp9CRuyyVqHS+Ly/RNkc1ILurqkE0Q=; b=xf3Lzy7bvj/TrEyNSvqA+Fbe8+tdwJYGgrt1fm+a/KeNC2YaOcYy/OeYKfy8DboLZQ 8aCA3nNPVEOAUhD8lgGCEoGL433a4k/OmsrAJxJAKKeT4PcPpCragwo3MQ8dXQKUgXYj 65rLzlepKHYpDr357xXBRWV/+SkJgNWSNFZeBTftdY2xyMZTETUcy/Tn50D0CmB3ezHm Wb2gkHKDDiLEgYQQsVjPiDIb5kflFsF1IDhmiwxu8rlciviqFXSsH+u6YyoVdAVoZrO5 4hHZ3+IYv/s9qV88iYAYJZItlHoPKK1hiv6x7x9byqIWVGSf9YULAncebJmfp/egecFx A4tA== MIME-Version: 1.0 X-Received: by 10.52.93.106 with SMTP id ct10mr8978517vdb.83.1374571165849; Tue, 23 Jul 2013 02:19:25 -0700 (PDT) In-Reply-To: References: <368qu85msgfhuk2j2s13qj0bqn4rkcint9@4ax.com> <51ED3CEB.1070706@gmail.com> Date: Tue, 23 Jul 2013 19:19:25 +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: 62 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374571174 news.xs4all.nl 15964 [2001:888:2000:d::a6]:40155 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51076 On Tue, Jul 23, 2013 at 6:06 PM, Duncan Booth wrote: > Chris Angelico wrote: > >> On Tue, Jul 23, 2013 at 12:08 AM, Michael Torrie >> wrote: >>> On 07/22/2013 06:51 AM, Chris Angelico wrote: >>>>> Thanks for the tip. I didn't know about SPF >>>>> http://en.wikipedia.org/wiki/Sender_Policy_Framework >>>> >>>> It's a great way of detecting legit vs forged mail. If anyone tries >>>> to send mail purporting to be from anything@kepl.com.au and the >>>> receiving mail server is checking SPF records, it'll be rejected >>>> after one cheap DNS lookup. It's a simple and cacheable way to ask >>>> the owning server, "Is this guy allowed to send mail for you?". (The >>>> 192.168 block in my SPF record above is permitted to allow some >>>> intranet conveniences; omit it unless you need it.) >>> >>> Yes setting SPF records will help your mail be accepted by other >>> servers, but I disagree with your appeal to make mail server SPF >>> handling as strict as your server does. SPF has problems in a number >>> of situations which could cause legitimate mail to be rejected. In >>> my last job I could only use SPF as one spam factor, not as a basis >>> for rejection. >> >> If legit mail is rejected for failing an SPF check, it's the sending >> admin's problem, not yours. You should never have problems with it if >> it's set up correctly. And since rejected mail gets reported to the >> transmitting MTA, you don't need to drop it in a spambox or anything. >> It's not spam, it's simply invalid mail (equivalent to something sent >> to a dud address). >> > If you want your emails to have the best chance of arriving your SPF should > list servers you use but not deny that there might be others. That usually makes the SPF record completely useless. The whole point is to say that random addresses on the internet _will not_ send mail from you. > I have a very common situation where an overly strict SPF may cause > problems: > > Like many people I have multiple email addresses which all end up in the > same inbox. The one I most commonly give out to businesses bounces the > email unchanged to the gmail inbox that I use. That means all emails I > receive through that email address appear to Google to have originated from > the forwarding servers. An SPF record from the original sender that claims > to have a complete list of originating servers will therefore fail > validation. Ah, there's a solution to this one. You simply use your own envelope-from address; SPF shouldn't be being checked for the From: header. Forwarding and using the original sender's address in the SMTP 'MAIL FROM' command is forging mail from them, so it is correct for that to be thrown out. The mail is coming from your own account, so you put your address in it, and you might even be able to put an uber-strict SPF record like "v=spf1 ip4:1.2.3.4 -all" which is quick to process and guarantees that nobody can pretend to forward mail on your behalf. The checks are for the *current connection*, not anything earlier. ChrisA