本文整理汇总了Python中mailer.Message.To方法的典型用法代码示例。如果您正苦于以下问题:Python Message.To方法的具体用法?Python Message.To怎么用?Python Message.To使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailer.Message
的用法示例。
在下文中一共展示了Message.To方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import To [as 别名]
def send_email(email_props, content):
""" Helper for sending emails"""
p = email_props
mess = Message(charset="utf-8")
mess.From = p.email_sender
mess.To = p.email_recipient
mess.Subject = p.email_subject
mess.Html = content
mess.Body = "Please enable HTML in your client to view this message."
sender = Mailer(p.email_server)
try:
sender.send(mess)
logger.info("Email [{}] was sent to: {}".format(mess.Subject, mess.To))
except Exception as exc:
logger.error("Problem sending email [{}] to [{}]: {}"
.format(p.email_subject, p.email_recipient, exc))
示例2: send_register_mail
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import To [as 别名]
def send_register_mail(user, pwd):
message = Message()
message.From = 'no-reply'
message.Body = "Ваш пароль: %s" % pwd
message.To = user['email']
message.Subject = 'Регистрация в системе'
try:
sender.send(message)
return True
except (
smtplib.SMTPAuthenticationError,
smtplib.SMTPDataError,
smtplib.SMTPConnectError,
smtplib.SMTPRecipientsRefused,
smtplib.SMTPSenderRefused,
smtplib.SMTPResponseException,
smtplib.SMTPServerDisconnected,
smtplib.SMTPHeloError,
smtplib.SMTPException
) as e:
print(e)
return False
示例3: process
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import To [as 别名]
if __name__ == "__main__":
# Use for debugging
# process()
while True:
now = datetime.now()
diff = (24 - now.hour) * 60 * 60 + (60 - now.minute) * 60 - now.second
for i in range(diff + 10 * 60 * 60, 0, -1):
print "\rSleeping for %s seconds..." % i,
sys.stdout.flush()
time.sleep(1)
print
message.Subject = ""
message.Html = ""
try:
process()
except KeyboardInterrupt:
sys.exit()
except:
try:
message.Subject = " InvoiceReport "
message.Subject += datetime.now().strftime("%d-%m")
message.To = "[email protected]"
message.CC = "[email protected]"
message.Html = "Invoice Script stopped Working"
print "something wrong with the script"
sender.send(message)
except:
print "Network problem"
示例4: Message
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import To [as 别名]
from mailer import Mailer
from mailer import Message
import urllib
msg1 = Message(From="[email protected]",
To=["[email protected]", "[email protected]"],
charset="utf-8")
msg1.Subject = "日本語のHTMLメール"
msg1.Html = """Hello, <b>日本語</b>"""
mailer = Mailer('smtp01.odn.ne.jp')
msg2 = Message(Body="ナイスボディー!", attachments=["picture.png"])
msg2.From = "[email protected]"
msg2.To = "[email protected]"
msg2.Subject = "日本語の添付ファイルメール"
msg2.charset = "utf-8"
mailer.send([msg1, msg2])
msg = Message()
msg.From = "[email protected]"
msg.To = "[email protected]"
msg.Subject = "テキストメール"
msg.Body = "これは日本語のキストメールでございます。"
msg.charset = "utf-8"
mailer.send(msg)
msg3 = Message(From="[email protected]",
To=["[email protected]", "[email protected]"],