sendmail smtplib.SMTP('localhost') Where is the email?

Chris Angelico rosuav at gmail.com
Thu May 30 18:13:53 EDT 2013


On Fri, May 31, 2013 at 5:48 AM, inq1ltd <inq1ltd at inqvista.com> wrote:
> python help,
>
> I've tried this code which I got from:
>
> http://www.tutorialspoint.com/python/python_sending_email.htm
>
> I build this file and run it
>
> After running the the file and I get
>
> "Successfully sent email"
>
> My question is why doesn't webmaster get an email?

First point: Please send *plain text* emails. Your message came out
double-spaced and with absolutely no indentation, which destroys the
structure of Python code. (Your script is sufficiently simple that
it's fairly clear how it had to be laid out, but when you force us to
use our crystal balls for simple stuff like indentation, we can't use
them again for something more important. The cooldown on these babies
is pretty stiff sometimes.)

Secondly, it helps a LOT to tell us what you're running under - Python
version, OS, etc. One easy way to do that is to quote the text that
the interactive interpreter opens with, eg:

Python 2.4.5 (#1, Jul 22 2011, 02:01:04)
[GCC 4.1.1] on mingw32

Python 3.4.0a0 (default:5dcd7ee0716a, Mar 30 2013, 08:17:06)
[GCC 4.7.2] on linux

Now, on to your actual code.

The docs say:
"""This method will return normally if the mail is accepted for at
least one recipient. Otherwise it will raise an exception. That is, if
this method does not raise an exception, then someone should get your
mail."""

That's nice confidence-inducing language, but I take exception (if
you'll pardon the pun) to the last part. The only thing this function
can know is that the mail has been accepted by the next hop. After
that... well, the internet is a scary place, anything could happen.
See if your SMTP server (the one running on localhost) has a nice log;
you may be able to watch the message get processed by the next hop.

By the way, I wouldn't bother with the try/except here. Just let the
exception bubble up and be emitted to stderr. It'll be more useful
that way :)

ChrisA



More information about the Python-list mailing list