我试图通过我的默认浏览器(雷鸟)从Python发送电子邮件。
这就是我所拥有的。
from urllib import quote
import webbrowser
def mailto(recipients, subject, body):
"recipients: string with comma-separated emails (no spaces!)"
webbrowser.open("mailto:%s?subject=%s&body=%s" %
(recipients, quote(subject), quote(body)))
body_template = """Hello %(name)s!
How are you?"""
def gen(email, name):
mailto(email, "Hi!", body_template % locals())
gen("joe@example.com", "Joe")
gen("jane@example.com,jill@example.com", "Jane and Jill")
此代码执行时没有错误,它正确地创建了电子邮件但实际上并没有发送它。脚本的输出是一个雷鸟电子邮件,等待某人按下"发送"被发送。 如何自动完成最后一块?