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 = 'ming@choozmo.com'
gmail_password='lzpxinencaawsjus'

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']




def send(msg_in,email):
    to = [email]
    msg = MIMEMultipart()
    msg['Subject'] = 'AI Spokesgirl 服務餘額不足 '
    
    msgAlternative = MIMEMultipart('alternative')
    msg.attach(msgAlternative)

    text = MIMEText(msg_in,'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...')

