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 = 'username@company.com'
receivers = "receivername@company.com"
message = """From: Sender Name <username@company.com>
To: Receiver Name <receivername@company.com>
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"