All the content are treated as a simple text at when you send a text message using Python. Even if you include HTML tags in a text message, it will display as simple text and HTML tags will not be formatted according to HTML syntax. But Python provides option to send an HTML message as actual HTML message.
For example you can see below code-
#!/shiva/bin/python
import smtplib
message = """From: From Person
To: To Person
MIME-Version: 1.0
Content-type: text/html
Subject: SMTP HTML e-mail test
This is an e-mail message to be sent in HTML format
This is HTML message.
This is headline.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
0 Comment(s)