Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Sending an HTML e-mail using Python

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 553
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: