-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtext mail.py
More file actions
26 lines (18 loc) · 708 Bytes
/
text mail.py
File metadata and controls
26 lines (18 loc) · 708 Bytes
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
import smtplib
import getpass
HOST = "smtp-mail.outlook.com"
PORT = 587
FROM_EMAIL = "<add from email address here>"
TO_EMAIL = "<add to email address here>"
PASSWORD = getpass.getpass("Enter password: ")
MESSAGE = """Subject: <add mail subject here>
<add mail content here>"""
smtp = smtplib.SMTP(HOST, PORT)
status_code, response = smtp.ehlo()
print(f"[*] Echoing the server: {status_code} {response}")
status_code, response = smtp.starttls()
print(f"[*] Starting TLS connection: {status_code} {response}")
status_code, response = smtp.login(FROM_EMAIL, PASSWORD)
print(f"[*] Logging in: {status_code} {response}")
smtp.sendmail(FROM_EMAIL, TO_EMAIL, MESSAGE)
smtp.quit()