Skip to content

Commit 2ce2c0a

Browse files
committed
Email snippets
1 parent e5cdf17 commit 2ce2c0a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

Python/Emails/mail-demo.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
import os
3+
import smtplib
4+
import imghdr
5+
from email.message import EmailMessage
6+
7+
EMAIL_ADDRESS = os.environ.get('EMAIL_USER')
8+
EMAIL_PASSWORD = os.environ.get('EMAIL_PASS')
9+
10+
11+
12+
msg = EmailMessage()
13+
msg['Subject'] = 'Check out Bronx as a puppy!'
14+
msg['From'] = EMAIL_ADDRESS
15+
msg['To'] = '[email protected]'
16+
17+
msg.set_content('This is a plain text email')
18+
19+
msg.add_alternative("""\
20+
<!DOCTYPE html>
21+
<html>
22+
<body>
23+
<h1 style="color:SlateGray;">This is an HTML Email!</h1>
24+
</body>
25+
</html>
26+
""", subtype='html')
27+
28+
29+
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
30+
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
31+
smtp.send_message(msg)

Python/Emails/simple.html

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<h1 style="color:SlateGray;">This is an HTML Email!</h1>
5+
</body>
6+
</html>

0 commit comments

Comments
 (0)