0

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

import smtplib
sender = 'igor.savinkin@gmail.com'
receivers = ['igor.savinkin@gmail.com']
message = """From: From Igor <igor.savinkin@gmail.com>
To: To Igor Savinkin <igor.savinkin@gmail.com>
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 ['igor.savinkin@gmail.com']

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.

Community
  • 1
  • 1
Igor Savinkin
  • 5,669
  • 8
  • 37
  • 69

1 Answers1

2

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.

Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252