def mailer_send(subject="!",
sender=None,
recipients=[],
body=None,
html=None,
attachments=[]):
try:
request = get_current_request()
if sender is None:
sender = request.registry.settings['lac.admin_email']
mailer = get_mailer(request)
message = Message(subject=subject,
sender=sender,
recipients=recipients,
body=body,
html=html)
for attachment in attachments:
attachment = Attachment(attachment.title,
attachment.mimetype,
attachment)
message.attach(attachment)
if transaction.get().status == Status.COMMITTED:
mailer.send_immediately(message)
else:
mailer.send(message)
except Exception:
pass
评论列表
文章目录