Recently need to do a function, count the number of bugs, and then email to the designated person, all the first to understand the use of Python to send mail
The code is as follows:
#coding: Utf-8
Import Smtplib
From email. Mimetext Import Mimetext
From email. Header Import Header
sender = ' [email protected] ' #发件人
receiver = [' [email protected] ', ' [email protected] '] #收件人 (if only one recipient can write directly: receiver = ' [email protected] ')
Span style= "font-family: Song body; Color: #3366ff; " >smtpserver = ' smtps.zhaopin.com.cn ' #发送邮件服务器
username = ' [email protected] ' #发送邮件服务器的登录用户名
password = ' user_1223 ' #发送邮件服务器的密码
msg = Mimetext (' #邮件内容
msg[' to ']= ', '. Join (receiver) #邮件内容显示的接收人 (if only one recipient can write directly: msg[' to ']=receiver, Of course, you can also directly replace receiver with the sender name you want to display.
msg[' from ']=sender #邮件内容显示的发件人
msg[' date ']= ' 2014-8-14 ' #邮件内容显示的发送时间
msg[' subject ']=u ' mail subject content ' #邮件的主题
SMTP = Smtplib. SMTP ()
smtp.connect (host= ' 192.168.11.8 ', port=25) #连接邮件服务器
smtp.login (username, password) #登录
Smtp.sendmail (sender, receiver, msg.as_string ()) #发送邮件
Smtp.quit ()