Name error ‘HTML’ is not defined using MIMEText object

#create a function to send the emails
def send_email (sender, receiver, sender_password, text_price):

    #create a MIMEmultipart object
    msg = MM()
    msg['Subject'] = "Newest Etheruem Price !"
    msg['From'] = sender
    msg['To'] = receiver

    #HTML for the message printed 
    HTML = """
    <h1> Newest Etheruem Price !</h1>
    <h2> """+text_price+""" </h2>

    #MIMEText oject 
    MTobj = MT(HTML, 'HTML')
    #MIMEText ojbect attachment 

    #Secure socket layer SSL context object 
    SSL_context = ssl.create_default_context()
    #Simple mail transfer protocol SMTP connection
    server = smtplib.SMTP_SSL(host="", port=465, context=SSL_context)
    #login to email
    server.login(sender, sender_passsword) 
    #send email
    server.sendmail(sender, receiver, msg.as_string()) 

the line of code that wont work is the MIMEText obj with MTobj = MT(HTML, 'HTML'). I am not sure why the HTML is not defined, any help would be appreciated, thank you

Read more here:

Content Attribution

This content was originally published by rsean at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: