I tried to run the following python script (copied from http://www.tutorialspoint.com/python/python_sending_email.htm) on a remote server to send an Email. I successfully received the Email in my mailbox, but unfortunately the content is always empty. Another problem is, if I slightly change the message within """From: xxx """, say delete this part From: sender Name
, then I could even receive the empty Email. What is the magic going on inside message line """xxx"""?
import smtplib
def send_Email2():
sender = '[email protected]'
receivers = "[email protected]"
message = """From: Sender Name <[email protected]>
To: Receiver Name <[email protected]>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('1xx.128.2.xxx',25)
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"