ming 3 years ago
parent
commit
484d2fdce3
1 changed files with 3 additions and 2 deletions
  1. 3 2
      api/mailer.py

+ 3 - 2
api/mailer.py

@@ -15,7 +15,7 @@ sent_from = gmail_user
 to = ['ming013r@gmail.com']
 
 
-msgAlternative.attach(text)
+
 def send(msg):
 
     msg = MIMEMultipart()
@@ -23,11 +23,12 @@ def send(msg):
     msgAlternative = MIMEMultipart('alternative')
     msg.attach(msgAlternative)
     text = MIMEText(text,'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)
+        server.sendmail(sent_from, to, msg.as_string())
         server.close()
         print ('Email sent!')
     except: