forked from alanhou/python-scripting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_html_content.py
More file actions
38 lines (32 loc) · 774 Bytes
/
Copy pathadd_html_content.py
File metadata and controls
38 lines (32 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os, smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import getpass
# host_name = 'smtp.gmail.com'
host_name = 'smtp.exmail.qq.com'
# host_name = 'smtp.163.com'
port = 465
sender = '发件人 email'
receiver = '收件人 email'
password = getpass.getpass()
text = MIMEMultipart()
text['Subject'] = 'Test HTML Content'
text['From'] = sender
text['To'] = receiver
msg = """\
<html>
<body>
<p>Hello there, <br>
Good day !!<br>
<a href="http://www.imdb.com">Home</a>
</p>
</body>
</html>
"""
html_content = MIMEText(msg, "html")
text.attach(html_content)
s = smtplib.SMTP_SSL(host_name, port)
print("Mail sent successfully !!")
s.login(sender, password)
s.sendmail(sender, receiver, text.as_string())
s.quit()