-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgames.py
49 lines (36 loc) · 1.07 KB
/
games.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
45
46
47
48
49
import os
import smtplib
import imghdr
from email.message import EmailMessage
from executable import to
# from weekly import toW, freqW
# from monthly import toM, freqM
# if freqW == 'weekly':
# to = toW
# elif freqM == 'monthly':
# to = toM
EMAIL_ADDRESS = os.environ.get('EMAIL_USER')
EMAIL_PASSWORD = os.environ.get('EMAIL_PASS')
msg = EmailMessage()
msg['Subject'] = 'Content About Music'
msg['From'] = EMAIL_ADDRESS
msg['To'] = to
msg.set_content('This is a plain text email...')
msg.add_alternative("""\
<!DOCTYPE html>
<html>
<body>
<h1 style="color:red;"> GAMES </h1>
</body>
</html>
""", subtype = 'html')
files = ['images\games.jpg']
for file in files:
with open(file, 'rb') as f:
file_data = f.read()
file_type = imghdr.what(f.name)
file_name = f.name
msg.add_attachment(file_data, maintype='image', subtype=file_type, filename=file_name)
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
smtp.send_message(msg)