howto send html mails using smtplib

  • Thread starter Philippe C. Martin
  • Start date
P

Philippe C. Martin

Hi,

I have the following problem:
1) I can use smtplib to send text messages
2) I can generate html
3) I want to email the html and want it to be seen by the email client as
html.

However, when I receive the message, the email client displays it as text
(code hereunder) - I assume it has to do with the MIMEText call but since I
cannot see any MIMEhtml .....

Any clue ?

Thanks

Philippe


#********************************************************************
def Mail(self,p_data):

you = wx.GetTextFromUser('EMAIL ADDRESS','ID')
if len(you) == 0:
return

self.__m_config = Config()

self.__m_config.Load()

me = self.__m_config.dict['ACCOUNT']
#me = '(e-mail address removed)'
host = self.__m_config.dict['SMTP']
s = smtplib.SMTP()
s.connect(host)


s.login(me,self.__m_config.GPW())

the_text = p_data
msg = MIMEText(the_text)
msg['To'] = you
msg['Subject'] = self.__m_config.dict['TITLE']
msg['From'] = self.__m_config.dict['FROM']
s.sendmail(me, [you], msg.as_string())
self.__m_list = []
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top