Re: Using pythons smtp server

2013-12-14 Thread Irmen de Jong
On 14-12-2013 1:46, Dennis Lee Bieber wrote:

   About then, I discovered the first two significant books on Python at
 Computer Literacy, and that an Amiga binary was available (Python 1.4, I
 think -- thanks, Irmin).

You're welcome, but my name is spelled Irmen, with an 'e' ;-)

Cheers
Irmen


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using pythons smtp server

2013-12-13 Thread Grant Edwards
On 2013-12-13, Vincent Davis vinc...@vincentdavis.net wrote:

 I have an app that generates a file one a day and would like to email it
 using pythons SMTP server.

You don't send mail using an SMTP server.  You receive mail using an
SMTP server.

 http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer
 The documentation is kinda sparse and I cant seem to find any good examples.

 Basically what I want to do; when my app runs it would initiate a SMTP
 server, send the attachment and shutdown the SMTP after.

Newsgroups: comp.lang.python
From: Grant Edwards invalid@invalid.invalid
Subject: Re: Using pythons smtp server
References: mailman.4046.1386908855.18130.python-l...@python.org
Followup-To:

On 2013-12-13, Vincent Davis vinc...@vincentdavis.net wrote:

 I have an app that generates a file one a day and would like to email
 it using pythons SMTP server.

You don't send mail using an SMTP server.  You receive mail using an 
SMTP server.  You send mail using an SMTP client.

 http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer
 The documentation is kinda sparse and I cant seem to find any good examples.

 Basically what I want to do; when my app runs it would initiate a SMTP
 server, send the attachment and shutdown the SMTP after.

https://www.google.com/search?q=python+send+email+smtp

-- 
Grant Edwards   grant.b.edwardsYow! The PINK SOCKS were
  at   ORIGINALLY from 1952!!
  gmail.comBut they went to MARS
   around 1953!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using pythons smtp server

2013-12-13 Thread Vincent Davis

 You don't send mail using an SMTP server.  You receive mail using an
 SMTP server.
 ​​


Um maybe, I guess it is a matter of perspective.

Let me rephrase my question. ​​I want to send an email using python but do
not want to use an external service. Does python have the ability to send
emails without installing additional software or using an external
server/service?
Maybe I am wrong, I thought examples like s = smtplib.SMTP('localhost')
​​ are using a local(outside of python) smtp server, like postfix.




Vincent Davis
720-301-3003


On Fri, Dec 13, 2013 at 9:40 AM, Grant Edwards invalid@invalid.invalidwrote:

 On 2013-12-13, Vincent Davis vinc...@vincentdavis.net wrote:

  I have an app that generates a file one a day and would like to email it
  using pythons SMTP server.

 You don't send mail using an SMTP server.  You receive mail using an
 SMTP server.

  http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer
  The documentation is kinda sparse and I cant seem to find any good
 examples.
 
  Basically what I want to do; when my app runs it would initiate a SMTP
  server, send the attachment and shutdown the SMTP after.

 Newsgroups: comp.lang.python
 From: Grant Edwards invalid@invalid.invalid
 Subject: Re: Using pythons smtp server
 References: mailman.4046.1386908855.18130.python-l...@python.org
 Followup-To:

 On 2013-12-13, Vincent Davis vinc...@vincentdavis.net wrote:

  I have an app that generates a file one a day and would like to email
  it using pythons SMTP server.

 You don't send mail using an SMTP server.  You receive mail using an
 SMTP server.  You send mail using an SMTP client.

  http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer
  The documentation is kinda sparse and I cant seem to find any good
 examples.
 
  Basically what I want to do; when my app runs it would initiate a SMTP
  server, send the attachment and shutdown the SMTP after.

 https://www.google.com/search?q=python+send+email+smtp

 --
 Grant Edwards   grant.b.edwardsYow! The PINK SOCKS were
   at   ORIGINALLY from 1952!!
   gmail.comBut they went to MARS
around 1953!!
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using pythons smtp server

2013-12-13 Thread Vincent Davis
Obviously I don't really know how this works. I have used python to send
email using my smtp server (whatever that may be gmail, postfix..)
But I don't want to do that. After a little more research I think what I
need to do is lookup the MX address of the address I want to send the email
too.
Then submit the email to that address using smtplib.SMTP
​Do I have that right?
​


Vincent Davis
720-301-3003


On Fri, Dec 13, 2013 at 10:24 AM, Dennis Lee Bieber
wlfr...@ix.netcom.comwrote:

 On Thu, 12 Dec 2013 18:01:58 -0700, Vincent Davis
 vinc...@vincentdavis.net declaimed the following:

 I have an app that generates a file one a day and would like to email it
 using pythons SMTP server.
 http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer
 The documentation is kinda sparse and I cant seem to find any good
 examples.
 
 Basically what I want to do; when my app runs it would initiate a SMTP
 server, send the attachment and shutdown the SMTP after.
 

 I suspect you don't want the server per se -- that's more a unit
 for
 receiving SMTP mail (sure, you can start it, but then you have to send the
 email to IT so it can relay it to the next server in the line).

 Look into the smtplib module (section 20.12 in the v2.7.2
 documentation) in order to send email TO a mail server
 --
 Wulfraed Dennis Lee Bieber AF6VN
 wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using pythons smtp server

2013-12-13 Thread Grant Edwards
On 2013-12-13, Vincent Davis vinc...@vincentdavis.net wrote:

 Obviously I don't really know how this works. I have used python to
 send email using my smtp server (whatever that may be gmail,
 postfix..) But I don't want to do that. After a little more research
 I think what I need to do is lookup the MX address of the address I
 want to send the email too.

 Then submit the email to that address using smtplib.SMTP

Maybe.  In theory, that will work -- and it did in the good old days
before SPAM (the electric kind) was invented.

But, many SMTP servers (the ones pointed to by the MX record) will not
accept mail from you unless you meet various requirements (which vary
considerably and the SMTP servers administrators try to keep secret).

For example you may have to be sending from an IP address who's
reverse-DNS lookup matches up with the from headers and with the MX
record for the domain you claim to be sending from.

Your mail might also get blocked/discarded if you're sending from
what's been identified as a dynamically allocated IP block (even if it
does have proper DNS and MX records).

-- 
Grant Edwards   grant.b.edwardsYow! Look into my eyes and
  at   try to forget that you have
  gmail.coma Macy's charge card!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using pythons smtp server

2013-12-13 Thread Chris Angelico
On Sat, Dec 14, 2013 at 4:13 AM, Vincent Davis vinc...@vincentdavis.net wrote:
 Let me rephrase my question. I want to send an email using python but do not
 want to use an external service. Does python have the ability to send emails
 without installing additional software or using an external server/service?

Any SMTP server you install has to do one of three things with the
mail you give it:

1) Accept it locally. Presumably the wrong thing to do here.
2) Deliver it to the authoritative SMTP server for the domain.
3) Deliver it to an intermediate server.

(Edit: Your next mail shows that you understand that, as looking up
the MX record is what I was going to say here.)

So if you want to avoid using an external intermediate server, you
need to find and talk to the authoritative server. Now, this is where
another big consideration comes in. What envelope From address are you
going to use? Is your own IP address allowed to send mail for that
domain? If not, you may be forced to use the legitimate server for
that domain. There are other concerns, too; if you don't have a nice
name to announce in the HELO, you might find your mail treated as
spam. But if you deal with all that, then yes, the only thing you need
to do is look up the MX record and pick the best server. (And then
deal with other concerns like coping with that one being down, which
is the advantage of having a local mail queue. But sometimes that
doesn't matter, like if you're sending to yourself for notifications.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using pythons smtp server

2013-12-13 Thread Vincent Davis
Grant, Chris
Thanks !!!
I guess in the end this is a bad idea, (for my purposes) I should just use
my gmail account smtp server.

Vincent Davis
720-301-3003


On Fri, Dec 13, 2013 at 11:15 AM, Chris Angelico ros...@gmail.com wrote:

 On Sat, Dec 14, 2013 at 4:13 AM, Vincent Davis vinc...@vincentdavis.net
 wrote:
  Let me rephrase my question. I want to send an email using python but do
 not
  want to use an external service. Does python have the ability to send
 emails
  without installing additional software or using an external
 server/service?

 Any SMTP server you install has to do one of three things with the
 mail you give it:

 1) Accept it locally. Presumably the wrong thing to do here.
 2) Deliver it to the authoritative SMTP server for the domain.
 3) Deliver it to an intermediate server.

 (Edit: Your next mail shows that you understand that, as looking up
 the MX record is what I was going to say here.)

 So if you want to avoid using an external intermediate server, you
 need to find and talk to the authoritative server. Now, this is where
 another big consideration comes in. What envelope From address are you
 going to use? Is your own IP address allowed to send mail for that
 domain? If not, you may be forced to use the legitimate server for
 that domain. There are other concerns, too; if you don't have a nice
 name to announce in the HELO, you might find your mail treated as
 spam. But if you deal with all that, then yes, the only thing you need
 to do is look up the MX record and pick the best server. (And then
 deal with other concerns like coping with that one being down, which
 is the advantage of having a local mail queue. But sometimes that
 doesn't matter, like if you're sending to yourself for notifications.)

 ChrisA
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using pythons smtp server

2013-12-13 Thread Chris Angelico
On Sat, Dec 14, 2013 at 5:27 AM, Vincent Davis vinc...@vincentdavis.net wrote:
 Grant, Chris
 Thanks !!!
 I guess in the end this is a bad idea, (for my purposes) I should just use
 my gmail account smtp server.

If you're sending from gmail, use whatever gmail specifies for
sending. Otherwise your mail will be seen as spoofed.

The converse of this is that, in my opinion, *every* domain should
have an SPF record and *every* mail server should check them. That
would eliminate a huge slab of forged mail, and it'd prevent some
stupid web email forms from doing the wrong thing and only finding out
that it's wrong years later.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using pythons smtp server

2013-12-13 Thread Grant Edwards
On 2013-12-13, Vincent Davis vinc...@vincentdavis.net wrote:
 Grant, Chris
 Thanks !!!

 I guess in the end this is a bad idea, (for my purposes) I should just use
 my gmail account smtp server.

If you're going to claim the mail is from somebody@gmail.com, then
yes you should definitly send it via Gmail's SMTP server.  Doing
anything else is going to be a long, losing battle involving you
learning more about SMTP and e-mail headers than you probably want to.

If you've got your own domain (which you're using as the from
address), a static IP, and your own MX record and corresponding SMTP
server, you should be able to set things up to send mail directly.

Many years ago (like 20), I used to configure my home Linux boxes to
send mail directly to the destination SMTP server while claiming to be
from grante@my-isp's-name.com.  At first it worked fine that way.
Then about about 12-15 years ago, I started having problems with some
servers refusing my mail.  I had a static IP address with a real,
official hostname, so I set up an MX record for that hostname, and
made sure my handshaking configuration was using a hostname that
mapped back to my static IP address.  That helped for a while, but
SMTP servers continued to get more and more paranoid.  Some SMTP
servers won't accept mail from an IP if they've determined is a
residential IP address even if you do have a domain that matches the
from address, an MX record, and everything else.

Eventually, I just gave up and started routing everything through the
official SMTP server associated with the e-mail address from which I
wanted to send the mail.

-- 
Grant Edwards   grant.b.edwardsYow! I'm having a MID-WEEK
  at   CRISIS!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Using pythons smtp server

2013-12-12 Thread Vincent Davis
I have an app that generates a file one a day and would like to email it
using pythons SMTP server.
http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer
The documentation is kinda sparse and I cant seem to find any good examples.

Basically what I want to do; when my app runs it would initiate a SMTP
server, send the attachment and shutdown the SMTP after.

Vincent Davis
-- 
https://mail.python.org/mailman/listinfo/python-list