-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (30 loc) · 1.05 KB
/
main.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
from email.message import EmailMessage as EM
import ssl, os, smtplib, imghdr
email_sender = '[email protected]'
email_pass = os.environ.get("EMAIL_PASS")
email_receiver, names = [], []
f = open("recipients_name.txt", "r")
for recipients in f:
if "\n" in recipients:
names.append(recipients[:-1])
else: names.append(recipients)
f = open("recipients_email.txt", "r")
for email in f:
if "\n" in email:
email_receiver.append(email[:-1])
else: email_receiver.append(email)
subject = 'New Py Tutorial'
em = EM()
em['From'] = email_sender
em['To'] = email_receiver
em['Subject'] = subject
for nickname, receiver in zip(names, email_receiver):
body = 'Hello ' + nickname + '''
you can access the new python tutorial through the link :
https://www.youtube.com/watch?v=g_j6ILT-X0k
'''
em.set_content(body)
context = ssl.create_default_context()
with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
smtp.login(email_sender, email_pass)
smtp.sendmail(email_sender, receiver, em.as_string())