Created
March 19, 2020 10:52
-
-
Save RyanAquino/5d64832e6ff57fea01d903d91c55723f to your computer and use it in GitHub Desktop.
Python Sending Emails via SMTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_email(): | |
contacts = ['ryan_aquino@trendmicro.com'] | |
msg = EmailMessage() | |
msg['Subject'] = 'Test subject' | |
msg['From'] = 'dcs_coc24x7@trendmicro.com' | |
msg['To'] = contacts | |
msg['Cc'] = contacts | |
test = 'hello' | |
msg.set_content(f""" | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1 style="color:SlateGray;">{test}</h1> | |
</body> | |
</html> | |
""", subtype='html') | |
with smtplib.SMTP('sjc1-rly.sdi.trendmicro.com') as smtp: | |
smtp.send_message(msg) | |
return 'Successfully send to receipt' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment