-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.py
More file actions
39 lines (32 loc) · 1.1 KB
/
mail.py
File metadata and controls
39 lines (32 loc) · 1.1 KB
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
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from config import DEFAULT_EMAIL_HEADER, DEFAULT_EMAIL_CONTENT
def send_alert_mail(sender_email, sender_password, receiver_email, gpu_stats):
#The mail addresses and password
sender_address = "caohoangtung201@gmail.com"
sender_pass = "38361067"
receiver_address = "caohoangtung2001@gmail.com"
message = MIMEMultipart()
message["From"] = sender_address
message["To"] = receiver_address
message["Subject"] = DEFAULT_EMAIL_HEADER
message.attach(
MIMEText(
f"""
{DEFAULT_EMAIL_CONTENT}
Thông tin GPU đây thưa các ngài
{gpu_stats}
""",
"plain"
)
)
session = smtplib.SMTP("smtp.gmail.com", 587) # use gmail with port
session.starttls()
session.login(sender_email, sender_password)
text = message.as_string()
session.sendmail(sender_email, receiver_email, text)
session.quit()
return True
# if __name__ == "__main__":
# send_alert_mail()