-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
45 lines (31 loc) · 1014 Bytes
/
app.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
33
34
35
36
37
38
39
40
41
42
43
44
import smtplib
import base64
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.mime.base import MIMEBase
from email import encoders
def sendMail():
# fromaddr = "[email protected]"
# toaddr = "[email protected]"
# password = 1993smyyadd1997
# body = "hello"
toaddr = raw_input("Please enter the toaddr email address: ")
fromaddr = raw_input("Please enter the fromaddr email address: ")
password = raw_input("Please enter your password: ")
body = raw_input("Please enter the message: \n")
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "SM Engage Campaign"
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, password)
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()
return {'raw': base64.urlsafe_b64encode(msg.as_string())}
def main():
print(sendMail())
if __name__ == "__main__":
main()