-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.py
45 lines (35 loc) · 1.19 KB
/
mail.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Tag is empty
# Please cancel the if clause after filling the email data
import smtplib
import ssl
from email.message import EmailMessage
def mail(body):
if True:
pass
else:
# Fill this part!...
# Define email sender and receiver
email_sender = ''#fill the mail address
email_password = ''#fill the password
email_receiver = ''#fill the mail addresses to
# Set the subject and body of the email
subject = 'analyses completed!'
if not body :
body = """
simulation has done. Check pls.
"""
em = EmailMessage()
em['From'] = email_sender
em['To'] = email_receiver
em['Subject'] = subject
em.set_content(body)
# Add SSL (layer of security)
context = ssl.create_default_context()
# Log in and send the email
with smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context) as smtp:
smtp.login(email_sender, email_password)
smtp.sendmail(email_sender, email_receiver, em.as_string())
if __name__ =='__main__':
mail('')