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
  • 相关阅读:
    快速排序——中位数
    DataGridView 在下拉框添加下来事件
    VS2015 调试时 编辑并继续不可用
    用soapUI测试webservice
    SQL Server 2008 表变量 临时表
    mvc 返回值
    asp.net 页面上的点击事件
    C# SQL 面试题自我总结
    cf contest 1458
    【CFR#655】F Omkar ans Modes
  • 原文地址:https://www.cnblogs.com/HCT118/p/4541957.html
Copyright © 2011-2022 走看看