Skip to content

Commit a4bff99

Browse files
committed
email success
1 parent fcc5f78 commit a4bff99

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

pysns/email_do.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,32 @@
88
email_password = ''
99
email_send = 'zhxhcoder@qq.com'
1010

11-
subject = 'subjec11t'
11+
# 主题
12+
subject = '主题-这是Python发送的邮件'
1213

1314
msg = MIMEMultipart()
1415
msg['From'] = email_user
1516
msg['To'] = email_send
1617
msg['Subject'] = subject
1718

18-
body = 'Hi there, sending this email from Python!'
19-
msg.attach(MIMEText(body, 'plain'))
20-
19+
# 附件
2120
filename = 'QR.png'
2221
attachment = open(filename, 'rb')
23-
2422
part = MIMEBase('application', 'octet-stream')
2523
part.set_payload(attachment.read())
2624
encoders.encode_base64(part)
2725
part.add_header('Content-Disposition', "attachment; filename= " + filename)
28-
2926
msg.attach(part)
27+
28+
# 内容
29+
body = '内容-这是远程发来的邮件,请注意接收并查收附件' + filename
30+
msg.attach(MIMEText(body, 'plain'))
31+
3032
text = msg.as_string()
3133
server = smtplib.SMTP_SSL('smtp.qq.com', 465)
3234
# server.starttls()
3335
server.login(email_user, email_password)
34-
36+
print("邮件发送...")
3537
server.sendmail(email_user, email_send, text)
36-
38+
print("发送成功")
3739
server.quit()

0 commit comments

Comments
 (0)