本文整理汇总了Python中smtplib.SMTP_SSL.send_message方法的典型用法代码示例。如果您正苦于以下问题:Python SMTP_SSL.send_message方法的具体用法?Python SMTP_SSL.send_message怎么用?Python SMTP_SSL.send_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类smtplib.SMTP_SSL
的用法示例。
在下文中一共展示了SMTP_SSL.send_message方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: email
# 需要导入模块: from smtplib import SMTP_SSL [as 别名]
# 或者: from smtplib.SMTP_SSL import send_message [as 别名]
def email(date):
msg = MIMEText("Hello!\n"
"Just wanted to let you know that you could not be signed up for %s.\n"
"Please sign up for that date manually, or if that was a seminar day, please "
"ignore this message.\n\n"
"Thanks,\n"
"Selenium Sniper" % date)
msg['Subject'] = 'Selenium—could not be signed up for %s' % date
msg['To'] = config['email']['name']
msg['From'] = config['email']['name']
s = SMTP(host=config['email']['server'], port=config['email']['port'])
s.login(user=config['email']['username'], password=config['email']['password'])
s.send_message(msg)
s.quit()
示例2: emit
# 需要导入模块: from smtplib import SMTP_SSL [as 别名]
# 或者: from smtplib.SMTP_SSL import send_message [as 别名]
def emit(self, record: LogRecord) -> None:
"""
Emit a record.
Format the record and send it to the specified addresses.
:param record: The record to send.
:raise KeyboardInterrupt: If a keyboard interrupt occurs during mail transmission, it will be reraised.
:raise SystemExit: If a ``sys.exit()`` interrupts the mail transmission, it will be reraised.
"""
# noinspection PyBroadException
try:
port = self.mailport
if not port:
port = SMTP_SSL_PORT if self.ssl else SMTP_PORT
if self.ssl:
smtp = SMTP_SSL(self.mailhost, port, timeout=self.timeout)
else:
smtp = SMTP(self.mailhost, port, timeout=self.timeout)
msg = EmailMessage()
msg['From'] = self.fromaddr
msg['To'] = ','.join(self.toaddrs)
msg['Subject'] = self.getSubject(record)
msg['Date'] = email.utils.localtime()
msg.set_content(self.format(record))
if self.username:
if self.secure is not None:
smtp.ehlo()
smtp.starttls(*self.secure)
smtp.ehlo()
smtp.login(self.username, self.password)
smtp.send_message(msg)
smtp.quit()
except (KeyboardInterrupt, SystemExit):
raise
except Exception:
self.handleError(record)
示例3: send_mail
# 需要导入模块: from smtplib import SMTP_SSL [as 别名]
# 或者: from smtplib.SMTP_SSL import send_message [as 别名]
def send_mail(price_dict):
server = SMTP_SSL(smtp_ssl_address,smtp_ssl_port)
server.login(smtp_ssl_username,smtp_ssl_password)
server.send_message(construct_email(price_dict))
server.quit()