本文整理汇总了Python中models.Email.send_at方法的典型用法代码示例。如果您正苦于以下问题:Python Email.send_at方法的具体用法?Python Email.send_at怎么用?Python Email.send_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Email
的用法示例。
在下文中一共展示了Email.send_at方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_email
# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import send_at [as 别名]
def send_email(data):
"""
This is a helper function for sending emails based on the settings
provided in the settings.py file.
"""
if not settings.URL:
abort(500,'Email provider URL is not set')
if not settings.API_KEY:
abort(500,'Email provider API_KEY is not set')
status = False
if settings.EMAIL_PROVIDER == 'MAILGUN':
status = send_email_using_mailgun(data, settings.URL, settings.API_KEY)
if status != 'success' and settings.AUTO_SWITCH_EMAIL_PROVIDER: #check to auto switch email provider
return send_email_using_mandrill(data, settings.ALT_URL, settings.ALT_API_KEY)
elif settings.EMAIL_PROVIDER == 'MANDRILL':
status = send_email_using_mandrill(data, settings.URL, settings.API_KEY)
if status != 'success' and settings.AUTO_SWITCH_EMAIL_PROVIDER: #check to auto switch email provider
return send_email_using_mailgun(data, settings.ALT_URL, settings.ALT_API_KEY)
if status == 'success': #Storing emails sent in the database
email = Email(to_name=data['to_name'], to_email=data['to'],
from_email=data['from'], from_name=data['from_name'],
subject=data['subject'], body=data['body'])
if 'send_at' in data and data['send_at']:
email.send_at = data['send_at']
db_session.add(email)
db_session.commit()
return status