Skip to content

Commit

Permalink
Email snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyMSchafer committed Mar 18, 2019
1 parent e5cdf17 commit 2ce2c0a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Python/Emails/mail-demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

import os
import smtplib
import imghdr
from email.message import EmailMessage

EMAIL_ADDRESS = os.environ.get('EMAIL_USER')
EMAIL_PASSWORD = os.environ.get('EMAIL_PASS')

contacts = ['[email protected]', '[email protected]']

msg = EmailMessage()
msg['Subject'] = 'Check out Bronx as a puppy!'
msg['From'] = EMAIL_ADDRESS
msg['To'] = '[email protected]'

msg.set_content('This is a plain text email')

msg.add_alternative("""\
<!DOCTYPE html>
<html>
<body>
<h1 style="color:SlateGray;">This is an HTML Email!</h1>
</body>
</html>
""", subtype='html')


with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
smtp.send_message(msg)
6 changes: 6 additions & 0 deletions Python/Emails/simple.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<h1 style="color:SlateGray;">This is an HTML Email!</h1>
</body>
</html>

0 comments on commit 2ce2c0a

Please sign in to comment.