-
Notifications
You must be signed in to change notification settings - Fork 1
/
mail.py
32 lines (24 loc) · 886 Bytes
/
mail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import os
def send_mail(receiver, subject, message):
me = "boyuan@boyuan12.me"
my_password = os.getenv("EMAIL_PASSWORD")
you = receiver
msg = MIMEMultipart('alternative')
msg['Subject'] = subject
msg['From'] = me
msg['To'] = you
html = message
part2 = MIMEText(html, 'html')
msg.attach(part2)
# Send the message via gmail's regular server, over SSL - passwords are being sent, afterall
s = smtplib.SMTP_SSL('mail.privateemail.com')
# uncomment if interested in the actual smtp conversation
# s.set_debuglevel(1)
# do the smtp auth; sends ehlo if it hasn't been sent already
s.login(me, my_password)
s.sendmail(me, you, msg.as_string())
s.quit()
# send_mail("boyuan@boyuan12.me", "Hello!", "<h1>Hello!</h1>")