# import smtplib

# msg="Testing"

# # initialize connection to our email server, we will use Outlook here
# smtp = smtplib.SMTP('web1012.dataplugs.com', port='465')

# smtp.ehlo()  # send the extended hello to our server
# smtp.starttls()  # tell server we want to communicate with TLS encryption

# smtp.login('howard.yuen@inloop-tech.com', 'iamfine@INLOOP')  # login to our email server

# # send our email message 'msg' to our boss
# smtp.sendmail('howard.yuen@inloop-tech.com',
#               'howard.yuen@inloop-tech.com',
#               msg.as_string())
              
# smtp.quit()  # finally, don't forget to close the connection

import smtplib
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr, formataddr


msg_str = 'this is a test email sending by python'
# msg = MIMEText(msg_str, 'plain', 'utf-8')
html = open("edm.html")
msg = MIMEText(html.read(), 'html')
msg['From'] = 'howard.yuen@inloop-tech.com'
msg['To'] = 'howard.yuen@inloop-tech.com'
msg['Subject'] = Header('python email test', 'utf-8').encode()

smtp = smtplib.SMTP('web1012.dataplugs.com',2525)
smtp.set_debuglevel(2)
smtp.connect('web1012.dataplugs.com',2525)
smtp.starttls()
smtp.login('howard.yuen@inloop-tech.com', 'iamfine@INLOOP')
smtp.sendmail('howard.yuen@inloop-tech.com', 'howard.yuen@inloop-tech.com', msg.as_string())
smtp.quit()

# import smtplib, ssl

# smtp_server = "mail.inloop-tech.com"
# port = 2525  # For starttls
# sender_email = "howard.yuen@inloop-tech.com"
# password = "iamfine@INLOOP" #input("Type your password and press enter: ")

# # Create a secure SSL context
# context = ssl.create_default_context()

# # Try to log in to server and send email
# try:
#     server = smtplib.SMTP(smtp_server,port)
#     server.connect(smtp_server,port)
#     server.ehlo() # Can be omitted
#     server.starttls(context=context) # Secure the connection
#     server.ehlo() # Can be omitted
#     server.login(sender_email, password)
#     # TODO: Send email here
# except Exception as e:
#     # Print any error messages to stdout
#     print(e)
# finally:
#     server.quit() 