本文整理汇总了Python中fivecents.lib.i18n.Messages.failedToSendEmail方法的典型用法代码示例。如果您正苦于以下问题:Python Messages.failedToSendEmail方法的具体用法?Python Messages.failedToSendEmail怎么用?Python Messages.failedToSendEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fivecents.lib.i18n.Messages
的用法示例。
在下文中一共展示了Messages.failedToSendEmail方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_email
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToSendEmail [as 别名]
def send_email(self):
"""
Will send an e-mail with to a given address.
Only authenticated users can use it.
"""
if not authorized(ValidAuthKitUser()):
return { "failure" : Messages.invalidSession() }
to_address = request.params.get('to_address')
subject = request.params.get('subject')
body = request.params.get('body')
if not to_address or not subject or not body:
return { "failure" : Messages.invalidArguments() }
from email.MIMEText import MIMEText
message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject
message['From'] = config['from_address']
message['To'] = to_address
try:
self.emailSender().send_mime(to_address, config['from_address'], message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }
示例2: send_email
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToSendEmail [as 别名]
def send_email(self):
if not authorized(ValidAuthKitUser()):
return { "failure" : Messages.invalidSession() }
try:
to_address = request.params['to_address']
subject = request.params['subject']
body = request.params['body']
except:
return { "failure" : Messages.invalidArguments() }
if to_address == "" or subject == "" or body == "":
return { "failure" : Messages.invalidArguments() }
from email.MIMEText import MIMEText
message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject
message['From'] = config['from_address']
message['To'] = to_address
try:
from fivecents.lib.mail import EmailSender
ms = EmailSender(to_addresses = to_address)
ms.send_mime(message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }
示例3: send_feedback
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToSendEmail [as 别名]
def send_feedback(self):
from_address = request.params.get('from_address')
subject = _("Feedback about %s ") % h.site_name()
body = request.params.get('body')
if not from_address or not subject or not body:
return { "failure" : Messages.invalidArguments() }
from email.MIMEText import MIMEText
message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject
message['From'] = from_address
message['To'] = config['email_to']
try:
self.emailSender().send_mime(config['email_to'], from_address, message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }
示例4: send_feedback
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToSendEmail [as 别名]
def send_feedback(self):
try:
from_address = request.params['from_address']
subject = _("Feedback about %s " % h.site_name())
body = request.params['body']
except:
return { "failure" : Messages.invalidArguments() }
if from_address == "" or subject == "" or body == "":
return { "failure" : Messages.invalidArguments() }
from email.MIMEText import MIMEText
message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject
message['From'] = from_address
message['To'] = config['email_to']
try:
from fivecents.lib.mail import EmailSender
ms = EmailSender(to_addresses = message['To'])
ms.send_mime(message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }
示例5: send_invitation
# 需要导入模块: from fivecents.lib.i18n import Messages [as 别名]
# 或者: from fivecents.lib.i18n.Messages import failedToSendEmail [as 别名]
def send_invitation(self):
model = request.environ["sqlalchemy.model"]
db = request.environ["sqlalchemy.session"]
if not authorized(ValidAuthKitUser()):
return { "failure" : Messages.invalidSession() }
try:
to_address = request.params['to_address']
subject = _("You have been invited to %s " % h.site_name())
body = request.params['body']
except:
return { "failure" : Messages.invalidArguments() }
if to_address == "" or subject == "" or body == "":
return { "failure" : Messages.invalidArguments() }
invitation = model.Invitation(
sender_uid = h.authenticated_user().uid,
to_address = to_address,
)
db.save(invitation)
db.commit()
c.invitation_link = h.site_url() + h.url_for(controller='signup', action='invitation', id=invitation.token)
from email.MIMEText import MIMEText
body = body + render_jinja('messages/invitation_footer.jinja')
message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
message['Subject'] = subject
message['From'] = config['from_address']
message['To'] = to_address
try:
from fivecents.lib.mail import EmailSender
ms = EmailSender(to_addresses = to_address)
ms.send_mime(message)
except Exception, e:
return { "failure" : Messages.failedToSendEmail(exception=e) }