来源:http://docs.python.org/library/email-examples.html
http://www.tutorialspoint.com/python/python_sending_email.htm
http://www.juyimeng.com/simple-python-send-mail-sample-code-with-smtp-auth.html
Here’s an example of how to create an HTML message with an alternative plain text version:[2]
#!/usr/bin/env python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# me == my email address
# you == recipient's email address
me = "my@email.com"
you = "your@email.com"
# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Link"
msg['From'] = me
msg['To'] = you
# Create the body of the message (a plain-text and an HTML version).
text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttp://www.python.org"
html = """\
<html>
<head></head>
<body>
<p>Hi!<br>
How are you?<br>
Here is the <a href="http://www.python.org">link</a> you wanted.
</p>
</body>
</html>
"""
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)
# Send the message via local SMTP server.
s = smtplib.SMTP('localhost')
# sendmail function takes 3 arguments: sender's address, recipient's address
# and message to send - here it is sent as one string.
s.sendmail(me, you, msg.as_string())
s.quit()
相关推荐
Examples such as spam e-mail detection are demonstrated. Chapter 4, News Topic Classification with Support Vector Machine, covers multiclass classification, Support Vector Machine, and how it is ...
For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others. ...
Python参考手册,官方正式版参考手册,chm版。以下摘取部分内容:Navigation index modules | next | Python » 3.6.5 Documentation » Python Documentation contents What’s New in Python What’s New In ...
Try It Out: Sending Mail with MailServer 323 Retrieving Internet E-mail 323 Parsing a Local Mail Spool with mailbox 323 Try It Out: Printing a Summary of Your Mailbox 324 Fetching Mail from a POP3...
Instead, this book focuses on network programming, using Python 3 for every example script and snippet of code at the Python prompt. These examples are intended to build a comprehensive picture of ...
object as an example. Typically in a computer program, you'll represent people as customers or employees. The properties that you store against them are things like the name, the SSN, the age, if ...
your FTP and e-mail tasks such as manipulating your Gmail account, and reading or sending emails from a script or creating a guest book for your web application. We learn to write email clients with ...
MAIL_USERNAME=email@example.com (服务器发验证码用的邮箱,开启了smtp服务的邮箱账号,程序里默认使用qq邮箱,修改config文件可成其它类型邮箱) MAIL_PASSWORD=password (上面邮箱的密码,注意qq邮箱使用特殊16位...
Instead, this book focuses on network programming, using Python 3 for every example script and snippet of code at the Python prompt. These examples are intended to build a comprehensive picture of how...
host :验证SMTP凭据的主机(例如: mail.example.com或smtp.gmail.com ) port :SMTP端口(通常为587、25或465) receivers :接收警报的收件人列表 跑步 monitor.py脚本从命令行运行,可以选择将一个或多个网站...
邮递员 Mail API框架,支持。 通过SMTP创建和调用RESTful API方法(仅通过将电子邮件发送到正确...cat msg | bin/mail.simple.py user@example.com test@example.com ... Hello World 有关更多信息,请参见或 。 执照
本文实例讲述了Python自动化运维之Ansible定义主机与组规则操作。分享给大家供大家参考,具体如下: 一 点睛 Ansible通过定义好的主机与组规则(Inventory)对...mail.example.com 192.168.1.21:2135 [webservers] foo
api = TestRailAPI ( "https://example.testrail.com/" , "example@mail.com" , "password" ) # if use environment variables # api = TestRailAPI() new_milestone = api . milestones . add_milestone
* export MAIL_USERNAME=<your email@example.com>(开启了smtp服务的邮箱账号,程序里默认使用163邮箱,可以修改成其它类型邮箱) * export MAIL_PASSWORD=(不一定是你的邮箱密码,比如163邮箱开启smtp服务会让你...
user @ box:〜#./goog-mail.py example.com或python goog-mail.py example.com 扫描“ uk.ibm.com”的结果: 正如Matthew Hickey和Jennifer Arcuri的《黑客之手》中所见 免责声明-我仅编辑和上传了此工具。 我...
$ mail2csv example/Date,Subject,From"Wed, 16 May 2018 20:05:16 +0000",An email,Bob <bob>"Wed, 16 May 2018 20:07:52 +0000",Also an email,Alice <alice> 默认情况下,仅显示Date , Subject和From标头。...
CVE-2021-26855 CVE-2021-26855的PoC-只是一个检查器-用法python3 CVE - 2021 - 26855. py - u https : // mail . example . com - c example . burpcollaborator . ...
从获取该类的最简单用法是像这样发送一次性电子邮件: ```python from classy_mail.generic import SimpleEmail#create the emailemail = SimpleEmail(subject=u'Welcome to mycoolwebsite',to_addr=u'user@example....
*/1 * * * * python /home/jinx/cpu-monitor.py 2>&1 >/dev/null | /usr/local/bin/echomail -k <Mandrill> -t mail@example.org 该命令将在成功时返回0,在失败时返回1 。 旗帜 旗帜 短旗 描述 必需的 - 钥匙 -k ...
user@example.org <<< 'Anker ist Aktion!' || 2> /dev/null 这意味着每天凌晨09:00,都要进行检查以查看锚点是否在运行。 Nagios / Icinga监控集成 定义新command : define command { command_name check...