zoukankan      html  css  js  c++  java
  • Python 实现发送、抄送邮件功能

    发送邮件
    问题
    
    在web.py中,如何发送邮件?
    解法
    
    在web.py中使用web.sendmail()发送邮件.
    
    web.sendmail('cookbook@webpy.org', 'user@example.com', 'subject', 'message')
    
    如果在web.config中指定了邮件服务器,就会使用该服务器发送邮件,否则,就根据/usr/lib/sendmail中的设置发送邮件。
    
    web.config.smtp_server = 'mail.mydomain.com'
    
    如果要发送邮件给多个收件人,就给to_address赋值一个邮箱列表。
    
    web.sendmail('cookbook@webpy.org', ['user1@example.com', 'user2@example.com'], 'subject', 'message')
    
    cc和bcc关键字参数是可选的,分别表示抄送和暗送接收人。这两个参数也可以是列表,表示抄送/暗送多人。
    
    web.sendmail('cookbook@webpy.org', 'user@example.com', 'subject', 'message', cc='user1@example.com', bcc='user2@example.com')
    
    headers参数是一个元组,表示附加标头信息(Addition headers)
    
    web.sendmail('cookbook@webpy.org', 'user@example.com', 'subject', 'message',
            cc='user1@example.com', bcc='user2@example.com',
            headers=({'User-Agent': 'webpy.sendmail', 'X-Mailer': 'webpy.sendmail',})
            )
    下载web.py并安装
    http://webpy.org/static/web.py-0.37.tar.gz
  • 相关阅读:
    [CQOI2011]放棋子
    [JSOI2015]染色问题
    [ZJOI2016]小星星
    [NOI2018]你的名字
    bzoj2393 Cirno的完美算数教室
    [CQOI2012]局部极小值
    CF768F Barrels and boxes
    bzoj4402 Claris的剑
    烽火SATA SSD DSS200-B
    添加防火墙规则
  • 原文地址:https://www.cnblogs.com/HCT118/p/4541957.html
Copyright © 2011-2022 走看看