Email Services这一章因为用的不多,因此大致过了一下,现在仔细看到后来会忘掉一大半。因此,到时候用到再看也不迟,这里先给个简单的例子:

import smtplib

def readManyLines():
    
"""Read lines from the user until they enter a line with a single
period, and return a single string.
"""
    result 
= ""
    
while 1:
        line 
= raw_input()
        
if line == '.'return result
        result 
= result + line + "\n"

servername
=raw_input("SMTP server name: ")
Fromaddress
=raw_input("From address: ")
Toaddress
=raw_input("To address: ")
print "Enter your message. To end, enter a line that begins with a"
print "period and has no other characters: "
MessageText
=readManyLines()
server
=smtplib.SMTP(servername)
server.sendmail(Fromaddress, Toaddress, MessageText)
server.quit()



标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
"五向定位"职业成长路线公开课(上海、南京、大连)
Google站内搜索


相关链接: