Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8d5c87

Browse files
authored
Add files via upload
1 parent 3aaab49 commit e8d5c87

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

python-email-html/html_email.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import smtplib
2+
3+
from email.message import EmailMessage
4+
from email.utils import make_msgid
5+
6+
msg = EmailMessage()
7+
8+
asparagus_cid = make_msgid()
9+
msg.add_alternative("""\
10+
<html>
11+
<head></head>
12+
<body>
13+
<p>Hello</p>
14+
<p>Here is an example of sending HTML email using Python. Please click on below link:
15+
<a href="https://www.roytuts.com/how-to-send-an-html-email-using-python/">
16+
Send an HTML email using Python
17+
</a>
18+
</p>
19+
</body>
20+
</html>
21+
""".format(asparagus_cid=asparagus_cid[1:-1]), subtype='html')
22+
23+
fromEmail = '[email protected]'
24+
toEmail = '[email protected]'
25+
26+
msg['Subject'] = 'HTML Message'
27+
msg['From'] = fromEmail
28+
msg['To'] = toEmail
29+
30+
s = smtplib.SMTP('smtp.gmail.com', 587)
31+
32+
s.starttls()
33+
34+
s.login(fromEmail, 'gmail password')
35+
s.send_message(msg)
36+
s.quit()

python-email-html/html_email_ssl.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import smtplib
2+
3+
from email.message import EmailMessage
4+
from email.utils import make_msgid
5+
6+
msg = EmailMessage()
7+
8+
asparagus_cid = make_msgid()
9+
msg.add_alternative("""\
10+
<html>
11+
<head></head>
12+
<body>
13+
<p>Hello</p>
14+
<p>Here is an example of sending HTML email using Python. Please click on below link:
15+
<a href="https://www.roytuts.com/how-to-send-an-html-email-using-python/">
16+
Send an HTML email using Python
17+
</a>
18+
</p>
19+
</body>
20+
</html>
21+
""".format(asparagus_cid=asparagus_cid[1:-1]), subtype='html')
22+
23+
fromEmail = '[email protected]'
24+
toEmail = '[email protected]'
25+
26+
msg['Subject'] = 'HTML Message'
27+
msg['From'] = fromEmail
28+
msg['To'] = toEmail
29+
30+
s = smtplib.SMTP_SSL('smtp.gmail.com', 465)
31+
32+
s.login(fromEmail, 'gmail password')
33+
s.send_message(msg)
34+
s.quit()

python-email-html/readme.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You can go through the tutorial https://www.roytuts.com/how-to-send-an-html-email-using-python/

0 commit comments

Comments
 (0)