zoukankan      html  css  js  c++  java
  • Foundations of Python Network Programming 读书笔记系列(3) Email Services

    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()


  • 相关阅读:
    Java学习day2
    Java 学习day1
    const
    数组
    scanf、printf、gets、puts的应用及区别
    指针数组和数组指针
    指针函数和函数指针
    nginx Windows版使用说明
    windows平台上nginx部署web.py(转)
    python安装程序是报这样的错UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in range(128)
  • 原文地址:https://www.cnblogs.com/coderzh/p/1234269.html
Copyright © 2011-2022 走看看