-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworksonmulti.py
38 lines (28 loc) · 910 Bytes
/
worksonmulti.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
import smtplib
import getpass
import database_query_builder as h
import guipython as gui
#7071LAKSa
emails = h.list_of_emails
print(emails)
HOST = "smtp-mail.outlook.com"
PORT = 587
FROM_EMAIL = "[email protected]"
TO_EMAILS = emails
PASSWORD = getpass.getpass("Enter password: ")
SUBJECT = gui.subject
BODY = gui.body
# Compose the email message
MESSAGE = f"Subject: {SUBJECT}\n\n{BODY}"
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}")
# Send email to each recipient
for TO_EMAIL in TO_EMAILS:
smtp.sendmail(FROM_EMAIL, TO_EMAIL, MESSAGE)
print(f"[*] Email sent to {TO_EMAIL}")
smtp.quit()