howto send html mails using smtplib

Discussion in 'Python' started by Philippe C. Martin, Jun 9, 2005.

  1. 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 = ''
    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 = []
     
    Philippe C. Martin, Jun 9, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Duy Nguyen

    send mails from asp.net pages

    Duy Nguyen, Aug 9, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    438
    Duy Nguyen
    Aug 11, 2003
  2. Tim Williams

    re: howto send html mails using smtplib

    Tim Williams, Jun 10, 2005, in forum: Python
    Replies:
    1
    Views:
    697
    Philippe C. Martin
    Jun 10, 2005
  3. Evan
    Replies:
    3
    Views:
    478
  4. Gabriel Genellina

    Re: smtplib send email by using gmail smtp server

    Gabriel Genellina, May 3, 2009, in forum: Python
    Replies:
    0
    Views:
    452
    Gabriel Genellina
    May 3, 2009
  5. Peter Tellgren
    Replies:
    1
    Views:
    372
    Alex Eiras
    Apr 23, 2009
Loading...

Share This Page