比这篇新的文章:
三赌徒问题
比这篇旧的文章: 华容道最短路径求解程序
作者: zsp007, 点击938次, 评论(0), 收藏者(1), , 打分:
所有评论,共0条:( 我也来说两句)
比这篇旧的文章: 华容道最短路径求解程序
Gmail 发信
语言: Python, 标签: 无 2008/10/01发布 1年前更新作者: zsp007, 点击938次, 评论(0), 收藏者(1), , 打分:
Python语言: Gmail 发信
01 #coding:utf-8
02 from email.mime.text import MIMEText
03 import smtplib
04
05 class Gamil (object ):
06 def __init__ (self ,account,password):
07 """
08 Gamil("zsp007","xxxx")
09 """
10 self .account=" %s @gmail.com" %account
11 self .password=password
12
13 def send (self ,to,title,content):
14 """
15 send('zsp007@gmail.com,zsp747@gmail.com")
16 """
17 server = smtplib.SMTP('smtp.gmail.com' )
18 server.docmd("EHLO server" )
19 server.starttls()
20 server.login(self .account,self .password)
21
22 msg = MIMEText(content)
23 msg['Content-Type' ]='text/plain; charset="utf-8"'
24 msg['Subject' ] = title
25 msg['From' ] = self .account
26 msg['To' ] = to
27 server.sendmail(self .account, to ,msg.as_string())
28 server.close()
29
30 if __name__=="__main__" :
31 gmail=Gamil("你的帐号" ,"你的密码" )
32 gmail.send("zsp007@gmail.com,zsp747@gmail.com" ,"你好,测试一下" ,"好好学习,天天向上" )
02 from email.mime.text import MIMEText
03 import smtplib
04
05 class Gamil (object ):
06 def __init__ (self ,account,password):
07 """
08 Gamil("zsp007","xxxx")
09 """
10 self .account=" %s @gmail.com" %account
11 self .password=password
12
13 def send (self ,to,title,content):
14 """
15 send('zsp007@gmail.com,zsp747@gmail.com")
16 """
17 server = smtplib.SMTP('smtp.gmail.com' )
18 server.docmd("EHLO server" )
19 server.starttls()
20 server.login(self .account,self .password)
21
22 msg = MIMEText(content)
23 msg['Content-Type' ]='text/plain; charset="utf-8"'
24 msg['Subject' ] = title
25 msg['From' ] = self .account
26 msg['To' ] = to
27 server.sendmail(self .account, to ,msg.as_string())
28 server.close()
29
30 if __name__=="__main__" :
31 gmail=Gamil("你的帐号" ,"你的密码" )
32 gmail.send("zsp007@gmail.com,zsp747@gmail.com" ,"你好,测试一下" ,"好好学习,天天向上" )
所有评论,共0条:( 我也来说两句)
代码
