ยปCore Development>Code coverage>Doc/includes/email-simple.py

Python code coverage for Doc/includes/email-simple.py

#countcontent
1n/a# Import smtplib for the actual sending function
2n/aimport smtplib
3n/a
4n/a# Import the email modules we'll need
5n/afrom email.message import EmailMessage
6n/a
7n/a# Open the plain text file whose name is in textfile for reading.
8n/awith open(textfile) as fp:
9n/a # Create a text/plain message
10n/a msg = EmailMessage()
11n/a msg.set_content(fp.read())
12n/a
13n/a# me == the sender's email address
14n/a# you == the recipient's email address
15n/amsg['Subject'] = 'The contents of %s' % textfile
16n/amsg['From'] = me
17n/amsg['To'] = you
18n/a
19n/a# Send the message via our own SMTP server.
20n/as = smtplib.SMTP('localhost')
21n/as.send_message(msg)
22n/as.quit()