File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
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
+ contacts = ['YourAddress@gmail.com' , 'test@example.com' ]
11
+
12
+ msg = EmailMessage ()
13
+ msg ['Subject' ] = 'Check out Bronx as a puppy!'
14
+ msg ['From' ] = EMAIL_ADDRESS
15
+ msg ['To' ] = 'YourAddress@gmail.com'
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 )
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < body >
4
+ < h1 style ="color:SlateGray; "> This is an HTML Email!</ h1 >
5
+ </ body >
6
+ </ html >
You can’t perform that action at this time.
0 commit comments