-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsend.py
32 lines (27 loc) · 838 Bytes
/
send.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.text import MIMEText
from algo import encrypt_msg
fromx = "[email protected]"
to = "[email protected]"
password = "password"
subject = "ENC: Sample mail"
message = input("Enter message to send: ").strip()
encrypted_msg = encrypt_msg(message)
msg = MIMEText(encrypted_msg)
msg['Subject'] = subject
msg['From'] = fromx
msg['To'] = to
print("\nSending email ...\n")
print("----------------------------")
print("From:\t", msg['From'])
print("To:\t", msg['To'])
print("Subject:", msg['Subject'])
print("Message:\n", encrypted_msg)
print("----------------------------")
print("\nMessage sent ... ", u'\u2713')
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.ehlo()
server.login(fromx, password)
server.sendmail(fromx, to, (msg.as_string()))
server.quit()