Skip to content

Instantly share code, notes, and snippets.

@RyanAquino
Created March 19, 2020 10:52
Show Gist options
  • Save RyanAquino/5d64832e6ff57fea01d903d91c55723f to your computer and use it in GitHub Desktop.
Save RyanAquino/5d64832e6ff57fea01d903d91c55723f to your computer and use it in GitHub Desktop.
Python Sending Emails via SMTP
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