SMTP sending mail failure

559 views Asked by At

I've got a simple SMTP mailing example from here and my modified it. My code is:

import smtplib
sender = '[email protected]'
receivers = ['[email protected]']
message = """From: From Igor <[email protected]>
To: To Igor Savinkin <[email protected]>
Subject: SMTP e-mail test
This is a test e-mail message from SMTP python.
"""

try:
   smtpObj = smtplib.SMTP('localhost')
   smtpObj.sendmail(sender, receivers, message)         
   print "Successfully sent email to " + receivers.__str__()
except SMTPException:
   print "Error: unable to send email"

Output is:

Successfully sent email to ['[email protected]']

Yet, in actuality I find no mails like these in my inbox. The spam folder is checked too! What's wrong? I use rhc (OpenShift) platform.

1

There are 1 answers

1
Serge Ballesta On

You send your mail to a local SMTP server (smtpObj = smtplib.SMTP('localhost')). IMHO it accepts it (request is syntactically correct) but is then not allowed (or not configured) to forward it to gmail. I'm not using OpenShift so I do not know how SMTP is configured there.

You should control how the local SMTP server is configured.