-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
33 lines (27 loc) · 815 Bytes
/
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
import smtplib
import datetime as dt
import random
try:
file = open("quotes_rest.txt")
except FileNotFoundError:
file = open("quotes.txt")
finally:
data = file.readlines()
sentence = random.choice(data)
data.remove(sentence)
with open("quotes_rest.txt", "w") as file:
for item in data:
file.write(item)
file.close()
now = dt.datetime.now()
now_weekday = now.weekday()
my_email = [email protected]
password = YOUR_PASSWORD
receiver = RECEIVER_EMAIL
with smtplib.SMTP("smtp.gmail.com", port=587) as connection:
connection.starttls()
connection.login(user=my_email, password=password)
if now_weekday == 1:
message = sentence
connection.sendmail(from_addr=my_email, to_addrs=receiver, msg=f"Subject:Monday motivation\n\n{message}")
#