import smtplib
import traceback
import os
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.message import EmailMessage
import codecs
gmail_user = 'edm@choozmo.com'
gmail_password='wqdsyqwvppmubitv'

sent_from = gmail_user
#to = ['jared@choozmo.com','nina.huang@choozmo.com','ana@choozmo.com','ming@choozmo.com','mike@choozmo.com','andy@choozmo.com','hana@choozmo.com','stacy@choozmo.com','wen@choozmo.com','yukyo@choozmo.com','fxp87257@gmail.com','noodlesloves@gmail.com']
to = ['jared@choozmo.com']

msg = MIMEMultipart()
msg['Subject'] = '[2021-06-11] 趨勢日報 | ChoozMo '
msg['From'] = 'edm@choozmo.com'
msg['To'] = 'jeweiliang@gmail.com'

msgAlternative = MIMEMultipart('alternative')
msg.attach(msgAlternative)

fr=codecs.open('c:/tmp/final.html','r','utf-8')
content=fr.read()
fr.close()

text = MIMEText(content,'html','utf-8')

msgAlternative.attach(text)
try:
    server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
    server.ehlo()
    server.login(gmail_user, gmail_password)
    server.sendmail(sent_from, to,  msg.as_string())
    server.close()
    print ('Email sent!')
except:
    traceback.print_exc()
    print ('Something went wrong...')