當前位置: 首頁>>代碼示例>>Python>>正文


Python Email.send_at方法代碼示例

本文整理匯總了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
開發者ID:darshanrp,項目名稱:email_service,代碼行數:34,代碼來源:email_service.py


注:本文中的models.Email.send_at方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。