Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51013 > unrolled thread

Simple Python script as SMTP server for outgoing e-mails?

Started byGilles <nospam@nospam.com>
First post2013-07-21 16:42 +0200
Last post2013-08-06 12:45 +0200
Articles 20 on this page of 56 — 16 participants

Back to article view | Back to comp.lang.python


Contents

  Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-21 16:42 +0200
    Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-22 00:48 +1000
      Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-21 18:19 +0200
        Re: Simple Python script as SMTP server for outgoing e-mails? Michael Torrie <torriem@gmail.com> - 2013-07-21 11:46 -0600
          Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-21 22:34 +0200
            Re: Simple Python script as SMTP server for outgoing e-mails? Ivan Shmakov <oneingray@gmail.com> - 2013-07-21 20:53 +0000
            Re: Simple Python script as SMTP server for outgoing e-mails? Michael Torrie <torriem@gmail.com> - 2013-07-21 18:28 -0600
              Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-22 14:11 +0200
                Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-22 22:29 +1000
                  Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-22 14:38 +0200
                    Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-22 22:51 +1000
                    Re: Simple Python script as SMTP server for outgoing e-mails? Michael Torrie <torriem@gmail.com> - 2013-07-22 08:08 -0600
                    Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-23 00:15 +1000
                      Re: Simple Python script as SMTP server for outgoing e-mails? Duncan Booth <duncan.booth@invalid.invalid> - 2013-07-23 08:06 +0000
                        Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-23 19:19 +1000
                          Re: Simple Python script as SMTP server for outgoing e-mails? Duncan Booth <duncan.booth@invalid.invalid> - 2013-07-23 10:06 +0000
                            Strange behaviour with os.linesep Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2013-07-23 13:42 +0200
                              Re: Strange behaviour with os.linesep Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-23 15:25 +0000
                                Re: Strange behaviour with os.linesep Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-23 19:41 -0400
                                Re: Strange behaviour with os.linesep Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-23 19:51 -0400
                                Re: Strange behaviour with os.linesep Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2013-07-24 09:02 +0200
                                Re: Strange behaviour with os.linesep Chris Angelico <rosuav@gmail.com> - 2013-07-24 17:39 +1000
                                Re: Strange behaviour with os.linesep Terry Reedy <tjreedy@udel.edu> - 2013-07-24 12:01 -0400
                            Re: Strange behaviour with os.linesep Jason Swails <jason.swails@gmail.com> - 2013-07-23 08:39 -0400
                            Re: Strange behaviour with os.linesep Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2013-07-23 15:10 +0200
                            Re: Strange behaviour with os.linesep Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2013-07-23 15:26 +0200
                            Re: Strange behaviour with os.linesep Jason Swails <jason.swails@gmail.com> - 2013-07-23 09:35 -0400
                            Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-24 07:37 +1000
                        Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-23 19:30 +1000
                        [OT] SPF - was Re: Simple Python script as SMTP server for outgoing e-mails? Michael Torrie <torriem@gmail.com> - 2013-07-23 09:12 -0600
                        Re: [OT] SPF - was Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-24 07:47 +1000
                        non sequitur: [OT] SPF - was Re: Simple Python script as SMTP server for outgoing e-mails? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-23 19:59 -0400
                          Re: non sequitur: [OT] SPF - was Re: Simple Python script as SMTP server for outgoing e-mails? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-24 01:42 +0000
                        Re: Simple Python script as SMTP server for outgoing e-mails? Sanjay Arora <sanjay.k.arora@gmail.com> - 2013-08-05 18:43 +0530
                    Re: Simple Python script as SMTP server for outgoing e-mails? Michael Torrie <torriem@gmail.com> - 2013-07-22 10:25 -0600
                    Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-23 02:32 +1000
                Re: Simple Python script as SMTP server for outgoing e-mails? "Eric S. Johansson" <esj@harvee.org> - 2013-07-22 08:54 -0400
                  Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-23 23:48 +0200
                Re: Simple Python script as SMTP server for outgoing e-mails? Michael Torrie <torriem@gmail.com> - 2013-07-22 08:10 -0600
                  Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-23 23:50 +0200
    Re: Simple Python script as SMTP server for outgoing e-mails? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-21 12:39 -0400
    Re: Simple Python script as SMTP server for outgoing e-mails? Grant Edwards <invalid@invalid.invalid> - 2013-07-21 21:01 +0000
      Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-22 14:13 +0200
      Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-22 14:19 +0200
        Re: Simple Python script as SMTP server for outgoing e-mails? Grant Edwards <invalid@invalid.invalid> - 2013-07-22 14:10 +0000
        Re: Simple Python script as SMTP server for outgoing e-mails? Michael Torrie <torriem@gmail.com> - 2013-07-22 08:21 -0600
        Re: Simple Python script as SMTP server for outgoing e-mails? Chris Angelico <rosuav@gmail.com> - 2013-07-23 02:12 +1000
        Re: Simple Python script as SMTP server for outgoing e-mails? Nobody <nobody@nowhere.com> - 2013-07-22 21:32 +0100
    Re: Simple Python script as SMTP server for outgoing e-mails? Kevin Walzer <kw@codebykevin.com> - 2013-07-22 10:14 -0400
      Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-07-23 23:53 +0200
        Re: Simple Python script as SMTP server for outgoing e-mails? Kevin Walzer <kw@codebykevin.com> - 2013-07-24 10:38 -0400
          Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-08-01 16:15 +0200
            Re: Simple Python script as SMTP server for outgoing e-mails? Wayne Werner <wayne@waynewerner.com> - 2013-08-03 06:47 -0500
              Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-08-06 12:44 +0200
            Re: Simple Python script as SMTP server for outgoing e-mails? Kevin Walzer <kw@codebykevin.com> - 2013-08-03 21:41 -0400
              Re: Simple Python script as SMTP server for outgoing e-mails? Gilles <nospam@nospam.com> - 2013-08-06 12:45 +0200

Page 1 of 3  [1] 2 3  Next page →


#51013 — Simple Python script as SMTP server for outgoing e-mails?

FromGilles <nospam@nospam.com>
Date2013-07-21 16:42 +0200
SubjectSimple Python script as SMTP server for outgoing e-mails?
Message-ID<gksnu85fe69utl50s4e1tik0bhinndls3m@4ax.com>
Hello

	Every once in a while, my ISP's SMTP server refuses to send
perfectly legit e-mails because it considers them as SPAM.

So I'd like to install a dead-simple SMTP server on my XP computer
just to act as SMTP backup server.
All I'd need is to change the SMTP address in my e-mail client, and
off they go. No need for anything else like user authentication or
SPAM control.

Is there a no-brainer, ready-to-use solution in Python that I could
use for this?

Thank you.

[toc] | [next] | [standalone]


#51014

FromChris Angelico <rosuav@gmail.com>
Date2013-07-22 00:48 +1000
Message-ID<mailman.4956.1374418117.3114.python-list@python.org>
In reply to#51013
On Mon, Jul 22, 2013 at 12:42 AM, Gilles <nospam@nospam.com> wrote:
> Hello
>
>         Every once in a while, my ISP's SMTP server refuses to send
> perfectly legit e-mails because it considers them as SPAM.
>
> So I'd like to install a dead-simple SMTP server on my XP computer
> just to act as SMTP backup server.
> All I'd need is to change the SMTP address in my e-mail client, and
> off they go. No need for anything else like user authentication or
> SPAM control.
>
> Is there a no-brainer, ready-to-use solution in Python that I could
> use for this?

Rather than write something from scratch, I'd look at deploying
something out-of-the-box - Postfix, for instance - which you will be
able to configure much faster than writing your own. And then you
could have it either send via your ISP or send directly to the
receiving MTA, without much extra effort.

ChrisA

[toc] | [prev] | [next] | [standalone]


#51016

FromGilles <nospam@nospam.com>
Date2013-07-21 18:19 +0200
Message-ID<pb2ou8577r2ahshc0h3oeqoe25dei9gv1o@4ax.com>
In reply to#51014
On Mon, 22 Jul 2013 00:48:29 +1000, Chris Angelico <rosuav@gmail.com>
wrote:
>Rather than write something from scratch, I'd look at deploying
>something out-of-the-box - Postfix, for instance - which you will be
>able to configure much faster than writing your own. And then you
>could have it either send via your ISP or send directly to the
>receiving MTA, without much extra effort.

Thank you but precisely, I was looking for a "ready-to-use solution in
Python" so that I wouldn't have to write it myself.

Also, I don't need a full-fledged SMTP server, just a tiny script that
will let me send the occasional e-mails from my e-mail client that my
ISP wrongly considers as SPAM.

So, does someone know of a good, SMTP server just to send e-mails?

Thank you.

[toc] | [prev] | [next] | [standalone]


#51018

FromMichael Torrie <torriem@gmail.com>
Date2013-07-21 11:46 -0600
Message-ID<mailman.4966.1374428821.3114.python-list@python.org>
In reply to#51016
On 07/21/2013 10:19 AM, Gilles wrote:
> So, does someone know of a good, SMTP server just to send e-mails?

What you're looking for is not an SMTP server but a Mail Transfer Agent,
called an MTA.

Pretty much all distros ship with an MTA by default, even if the SMTP
server part of it isn't installed or running. And often the MTA is, for
compatibility reasons, /usr/sbin/sendmail.

http://stackoverflow.com/questions/73781/sending-mail-via-sendmail-from-python

I'm sure there are MTA's implemented in python. Now that you know what
they are called (not SMTP servers!) you can search for them.

Dennis is correct, though, that most ISPs do block outbound port 25
connections for security and spam reasons, and require you to use their
SMTP server, which precludes the use of the local MTA.

[toc] | [prev] | [next] | [standalone]


#51019

FromGilles <nospam@nospam.com>
Date2013-07-21 22:34 +0200
Message-ID<hbhou89g1ie8igtrpl24ajibc2251ea1po@4ax.com>
In reply to#51018
On Sun, 21 Jul 2013 11:46:52 -0600, Michael Torrie <torriem@gmail.com>
wrote:
>What you're looking for is not an SMTP server but a Mail Transfer Agent,
>called an MTA.
>
>Pretty much all distros ship with an MTA by default, even if the SMTP
>server part of it isn't installed or running. And often the MTA is, for
>compatibility reasons, /usr/sbin/sendmail.
>
>http://stackoverflow.com/questions/73781/sending-mail-via-sendmail-from-python
>
>I'm sure there are MTA's implemented in python. Now that you know what
>they are called (not SMTP servers!) you can search for them.
>
>Dennis is correct, though, that most ISPs do block outbound port 25
>connections for security and spam reasons, and require you to use their
>SMTP server, which precludes the use of the local MTA.

Thanks for the infos. Ideally, I was looking for a simple Windows app
as MTA, but a Python script is OK.

I'm not sure my ISP blocks outbound port 25 connections. I'll
experiment with a small Linux box.

I wist they would use a smarter SPAM filter that wouldn't flag
perfectly legit-looking outgoing e-mails.

[toc] | [prev] | [next] | [standalone]


#51021

FromIvan Shmakov <oneingray@gmail.com>
Date2013-07-21 20:53 +0000
Message-ID<87siz7tz2k.fsf@violet.siamics.net>
In reply to#51019
>>>>> Gilles  <nospam@nospam.com> writes:
>>>>> On Sun, 21 Jul 2013 11:46:52 -0600, Michael Torrie wrote:

	[Cross-posting to news:comp.mail.misc.]

 >> What you're looking for is not an SMTP server but a Mail Transfer
 >> Agent, called an MTA.

[...]

 >> Dennis is correct, though, that most ISPs do block outbound port 25
 >> connections for security and spam reasons, and require you to use
 >> their SMTP server, which precludes the use of the local MTA.

 > I'm not sure my ISP blocks outbound port 25 connections.  I'll
 > experiment with a small Linux box.

	There's yet another issue: certain email "operators" may block
	/inbound/ port 25 connections from ISP "customer" networks.

 > I wist they would use a smarter SPAM filter that wouldn't flag
 > perfectly legit-looking outgoing e-mails.

	FWIW, it may also be possible to use an email service (such as
	Google Mail) provided by a third-party.

-- 
FSF associate member #7257

[toc] | [prev] | [next] | [standalone]


#51025

FromMichael Torrie <torriem@gmail.com>
Date2013-07-21 18:28 -0600
Message-ID<mailman.4969.1374452915.3114.python-list@python.org>
In reply to#51019
On 07/21/2013 02:34 PM, Gilles wrote:
> Thanks for the infos. Ideally, I was looking for a simple Windows app
> as MTA, but a Python script is OK.

The Sendmail MTA has been ported to many platforms including windows.
But...

> I'm not sure my ISP blocks outbound port 25 connections. I'll
> experiment with a small Linux box.

Having spent a long time managing e-mail servers, everything Ivan said
in his reply is true as well.  I had forgotten a lot of that since I
haven't been running my own mail server (MTA or server part) in a while.
 I've sold my soul to Google for e-mail now with Google Apps for my
domain.

> I wist they would use a smarter SPAM filter that wouldn't flag
> perfectly legit-looking outgoing e-mails.

But then how would it know that legit-looking e-mails aren't in fact
SPAM?  E-mail is starting to be an almost intractable problem.  No
wonder the younger generations are just abandoning it entirely in favor
of centralized, cathedral-style messaging systems such as facebook.

[toc] | [prev] | [next] | [standalone]


#51031

FromGilles <nospam@nospam.com>
Date2013-07-22 14:11 +0200
Message-ID<368qu85msgfhuk2j2s13qj0bqn4rkcint9@4ax.com>
In reply to#51025
On Sun, 21 Jul 2013 18:28:27 -0600, Michael Torrie <torriem@gmail.com>
wrote:
>The Sendmail MTA has been ported to many platforms including windows.
>But...

Thanks for the tip. Since I couldn't find a good, basic, native
Windows app, I was indeed about to look at eg. Exim + Cygwin, and
resort to a Linux appliance if none footed the bill.

>> I'm not sure my ISP blocks outbound port 25 connections. I'll
>> experiment with a small Linux box.
>
>Having spent a long time managing e-mail servers, everything Ivan said
>in his reply is true as well.  I had forgotten a lot of that since I
>haven't been running my own mail server (MTA or server part) in a while.

Indeed, I had forgotten about some MTAs refusing incoming e-mails from
other ISP's customer hosts. I'll experiment.

>But then how would it know that legit-looking e-mails aren't in fact
>SPAM?

It generally does a good job, but every once in a while, some
perfectly good e-mail I'm sending is flagged as SPAM. To keep all my
e-mails in the same client, I'd rather use a local MTA than sending
the e-mail from Gmail.

Thank you.

[toc] | [prev] | [next] | [standalone]


#51034

FromChris Angelico <rosuav@gmail.com>
Date2013-07-22 22:29 +1000
Message-ID<mailman.4973.1374496190.3114.python-list@python.org>
In reply to#51031
On Mon, Jul 22, 2013 at 10:11 PM, Gilles <nospam@nospam.com> wrote:
> On Sun, 21 Jul 2013 18:28:27 -0600, Michael Torrie <torriem@gmail.com>
> wrote:
>>Having spent a long time managing e-mail servers, everything Ivan said
>>in his reply is true as well.  I had forgotten a lot of that since I
>>haven't been running my own mail server (MTA or server part) in a while.
>
> Indeed, I had forgotten about some MTAs refusing incoming e-mails from
> other ISP's customer hosts. I'll experiment.

One thing to check when you change how you send mail is your SPF
record. I run the mail server for kepl.com.au and have set its SPF to:

"v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all"

If your SPF is as strict as mine (and if it's not, please make it so,
for the sake of the rest of the world!), you'll want to check it
before you start sending mail directly from your own computer.
Otherwise your mail _will_ be rejected as spam.

ChrisA

[toc] | [prev] | [next] | [standalone]


#51036

FromGilles <nospam@nospam.com>
Date2013-07-22 14:38 +0200
Message-ID<at9qu8tq4gbp5rfgd7mq2eo8ui6uh3vnvg@4ax.com>
In reply to#51034
On Mon, 22 Jul 2013 22:29:42 +1000, Chris Angelico <rosuav@gmail.com>
wrote:
>One thing to check when you change how you send mail is your SPF
>record. I run the mail server for kepl.com.au and have set its SPF to:
>
>"v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all"
>
>If your SPF is as strict as mine (and if it's not, please make it so,
>for the sake of the rest of the world!), you'll want to check it
>before you start sending mail directly from your own computer.
>Otherwise your mail _will_ be rejected as spam.

Thanks for the tip. I didn't know about SPF
http://en.wikipedia.org/wiki/Sender_Policy_Framework

[toc] | [prev] | [next] | [standalone]


#51037

FromChris Angelico <rosuav@gmail.com>
Date2013-07-22 22:51 +1000
Message-ID<mailman.4974.1374497482.3114.python-list@python.org>
In reply to#51036
On Mon, Jul 22, 2013 at 10:38 PM, Gilles <nospam@nospam.com> wrote:
> On Mon, 22 Jul 2013 22:29:42 +1000, Chris Angelico <rosuav@gmail.com>
> wrote:
>>One thing to check when you change how you send mail is your SPF
>>record. I run the mail server for kepl.com.au and have set its SPF to:
>>
>>"v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all"
>>
>>If your SPF is as strict as mine (and if it's not, please make it so,
>>for the sake of the rest of the world!), you'll want to check it
>>before you start sending mail directly from your own computer.
>>Otherwise your mail _will_ be rejected as spam.
>
> 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.)

ChrisA

[toc] | [prev] | [next] | [standalone]


#51041

FromMichael Torrie <torriem@gmail.com>
Date2013-07-22 08:08 -0600
Message-ID<mailman.4978.1374502132.3114.python-list@python.org>
In reply to#51036
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.

[toc] | [prev] | [next] | [standalone]


#51045

FromChris Angelico <rosuav@gmail.com>
Date2013-07-23 00:15 +1000
Message-ID<mailman.4980.1374502532.3114.python-list@python.org>
In reply to#51036
On Tue, Jul 23, 2013 at 12:08 AM, Michael Torrie <torriem@gmail.com> 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).

ChrisA

[toc] | [prev] | [next] | [standalone]


#51074

FromDuncan Booth <duncan.booth@invalid.invalid>
Date2013-07-23 08:06 +0000
Message-ID<XnsA2065B2C39831duncanbooth@127.0.0.1>
In reply to#51045
Chris Angelico <rosuav@gmail.com> wrote:

> On Tue, Jul 23, 2013 at 12:08 AM, Michael Torrie <torriem@gmail.com>
> 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.

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.

It isn't Google's fault: they can't ignore the forwarding step otherwise 
spammers could bypass SPF simply by claiming to be forwarding the emails. 
It is simply a limitation of the SPF protocol. Fortunately they only use 
SPF as one indicator so real messages still get through.

-- 
Duncan Booth

[toc] | [prev] | [next] | [standalone]


#51076

FromChris Angelico <rosuav@gmail.com>
Date2013-07-23 19:19 +1000
Message-ID<mailman.4997.1374571174.3114.python-list@python.org>
In reply to#51074
On Tue, Jul 23, 2013 at 6:06 PM, Duncan Booth
<duncan.booth@invalid.invalid> wrote:
> Chris Angelico <rosuav@gmail.com> wrote:
>
>> On Tue, Jul 23, 2013 at 12:08 AM, Michael Torrie <torriem@gmail.com>
>> 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

[toc] | [prev] | [next] | [standalone]


#51079

FromDuncan Booth <duncan.booth@invalid.invalid>
Date2013-07-23 10:06 +0000
Message-ID<XnsA2067049ADEF7duncanbooth@127.0.0.1>
In reply to#51076
Chris Angelico <rosuav@gmail.com> wrote:
> On Tue, Jul 23, 2013 at 6:06 PM, Duncan Booth
<duncan.booth@invalid.invalid> wrote:
>> 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.
> 

<sarcasm>
Excellent idea, I'll tell the email forwarding service to rewrite their 
system immediately. Or I could just tell Google to rewrite their email 
system to know about and strip off the forwarding service's headers: that's 
probably about as easy. Or maybe I could just ask you to add the  
forwarder's SPF record into your own?
</sarcasm>

I know that I could arrange things so that my emails don't trigger this 
situation, but that isn't the point. The point is that this situation 
happens quite commonly, therefore you as the sender of an email with a 
strict SPF are going to find systems rejecting emails you send that would 
get through if you have a less strict one.

That is of course your choice, but many users of email would prefer to 
maximise the chance of the email they send arriving rather than reducing 
slightly the chance of people they may not even know receiving spam.

You could also try combining SPF with DKIM although that has its own, 
different failure scenarios.

-- 
Duncan Booth

[toc] | [prev] | [next] | [standalone]


#51081 — Strange behaviour with os.linesep

FromVincent Vande Vyvre <vincent.vandevyvre@swing.be>
Date2013-07-23 13:42 +0200
SubjectStrange behaviour with os.linesep
Message-ID<mailman.5001.1374580194.3114.python-list@python.org>
In reply to#51079
On Windows a script where de endline are the system line sep, the files 
are open with a double line in Eric4, Notepad++ or Gedit but they are 
correctly displayed in the MS Bloc-Notes.

Example with this code:
----------------------------------------------
# -*- coding: utf-8 -*-

import os
L_SEP = os.linesep

def write():
     strings = ['# -*- coding: utf-8 -*-\n',
                 'import os\n',
                 'import sys\n']
     with open('writetest.py', 'w') as outf:
         for s in strings:
             outf.write(s.replace('\n', L_SEP))

write()
----------------------------------------------

The syntax `s.replace('\n', L_SEP)`is required for portability.

Regards
-
Vincent V.V

[toc] | [prev] | [next] | [standalone]


#51092 — Re: Strange behaviour with os.linesep

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-07-23 15:25 +0000
SubjectRe: Strange behaviour with os.linesep
Message-ID<51eea057$0$29971$c3e8da3$5496439d@news.astraweb.com>
In reply to#51081
On Tue, 23 Jul 2013 13:42:13 +0200, Vincent Vande Vyvre wrote:

> On Windows a script where de endline are the system line sep, the files
> are open with a double line in Eric4, Notepad++ or Gedit but they are
> correctly displayed in the MS Bloc-Notes.

I suspect the problem lies with Eric4, Notepad++ and Gedit. Do you 
perhaps have to manually tell them that the file uses Windows line 
separators?

I recommend opening the file in a hex editor and seeing for yourself what 
line separators are used.


> Example with this code:
> ----------------------------------------------
> # -*- coding: utf-8 -*-
> 
> import os
> L_SEP = os.linesep
> 
> def write():
>      strings = ['# -*- coding: utf-8 -*-\n',
>                  'import os\n',
>                  'import sys\n']
>      with open('writetest.py', 'w') as outf:
>          for s in strings:
>              outf.write(s.replace('\n', L_SEP))
> 
> write()
> ----------------------------------------------
> 
> The syntax `s.replace('\n', L_SEP)`is required for portability.

I don't think it is. Behaviour is a little different between Python 2 and 
3, but by default, Python uses "Universal Newlines". When you open a file 
in text mode, arbitrary line separators should be automatically 
translated to \n when reading, and \n will be automatically translated to 
os.line_sep when writing.


http://docs.python.org/3/library/functions.html#open
http://docs.python.org/2/library/functions.html#open

Some further discussion here:

http://stackoverflow.com/questions/12193047/is-universal-newlines-mode-
supposed-to-be-default-behaviour-for-open-in-python



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#51110 — Re: Strange behaviour with os.linesep

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-07-23 19:41 -0400
SubjectRe: Strange behaviour with os.linesep
Message-ID<mailman.5020.1374622873.3114.python-list@python.org>
In reply to#51092
On 23 Jul 2013 15:25:12 GMT, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> declaimed the following:

>On Tue, 23 Jul 2013 13:42:13 +0200, Vincent Vande Vyvre wrote:
>
>> On Windows a script where de endline are the system line sep, the files
>> are open with a double line in Eric4, Notepad++ or Gedit but they are
>> correctly displayed in the MS Bloc-Notes.
>
>I suspect the problem lies with Eric4, Notepad++ and Gedit. Do you 
>perhaps have to manually tell them that the file uses Windows line 
>separators?
>
	Don't know about those, but SciTE I know has both an menu option for
line ending (<cr><lf>, <lf>, <cr>), and one for "convert line endings"

	I also know Windows Notepad (at least on WinXP) would have the opposite
problem: <lf> termination files were displayed as single lines (Wordpad,
OTOH, correctly parsed those).
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#51111 — Re: Strange behaviour with os.linesep

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-07-23 19:51 -0400
SubjectRe: Strange behaviour with os.linesep
Message-ID<mailman.5021.1374623529.3114.python-list@python.org>
In reply to#51092
On 23 Jul 2013 15:25:12 GMT, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> declaimed the following:


>I don't think it is. Behaviour is a little different between Python 2 and 
>3, but by default, Python uses "Universal Newlines". When you open a file 

	Oh? When did that change come about... So far as I recall, Python 2.x
introduced a "universal newline" mode character for the open() function.
IE, one had to explicitly ask for universal mode during the open.

	Python 2.7 help file
"""
open(filename[, mode[, bufsize]]) 

	<snip>

to 'r'. The default is to use text mode, which may convert '\n' characters
to a platform-specific representation on writing and back on reading. Thus,
when opening a binary file, you should append 'b' to the mode value to open
the file in binary mode, which will improve portability. (Appending 'b' is 

	<snip>

In addition to the standard fopen() values mode may be 'U' or 'rU'. Python
is usually built with universal newline support; supplying 'U' opens the
file as a text file, but lines may be terminated by any of the following:
the Unix end-of-line convention '\n', the Macintosh convention '\r', or the
Windows convention '\r\n'. All of these external representations are seen
as '\n' by the Python program. If Python is built without universal newline
support a mode with 'U' is the same as normal text mode. Note that file
objects so opened also have an attribute called newlines which has a value
of None (if no newlines have yet been seen), '\n', '\r', '\r\n', or a tuple
containing all the newline types seen.
"""

	Seems to be silent with regards to /writing/; suspect writing will use
the system convention unless using "wb"/"ab" to force binary mode.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.python


csiph-web