本文整理汇总了Python中flaskext.mail.Message.add_recipient方法的典型用法代码示例。如果您正苦于以下问题:Python Message.add_recipient方法的具体用法?Python Message.add_recipient怎么用?Python Message.add_recipient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flaskext.mail.Message
的用法示例。
在下文中一共展示了Message.add_recipient方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: notify
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def notify(snipe, index):
""" Notify this snipe that their course is open"""
course = '%s:%s:%s' % (snipe.subject, snipe.course_number, snipe.section)
if snipe.user.email:
attributes = {
'email': snipe.user.email,
'subject': snipe.subject,
'course_number': snipe.course_number,
'section': snipe.section,
}
# build the url for prepopulated form
url = 'http://sniper.rutgers.io/?%s' % (urllib.urlencode(attributes))
register_url = 'https://sims.rutgers.edu/webreg/editSchedule.htm?login=cas&semesterSelection=92015&indexList=%s' % (index)
email_text = 'A course (%s) that you were watching looks open. Its index number is %s. Click the link below to register for it!\n\n %s \n\n If you don\'t get in, visit this URL: \n\n %s \n\n to continue watching it.\n\n Send any feedback to [email protected]' % (course, index, register_url, url)
# send out the email
message = Message('[Course Sniper](%s) is open' %(course), sender=EMAIL_SENDER)
message.body = email_text
message.add_recipient(snipe.user.email)
message.add_recipient(snipe.user.email)
mail.send(message)
db.session.delete(snipe)
db.session.commit()
app.logger.warning('Notified user: %s about snipe %s' % (snipe.user, snipe))
示例2: test_sendto_properly_set
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def test_sendto_properly_set(self):
msg = Message(
subject="subject", recipients=["[email protected]"], cc=["[email protected]"], bcc=["[email protected]"]
)
self.assertEqual(len(msg.send_to), 3)
msg.add_recipient("[email protected]")
self.assertEqual(len(msg.send_to), 3)
示例3: test_recipients_properly_initialized
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def test_recipients_properly_initialized(self):
msg = Message(subject="subject")
self.assertEqual(msg.recipients, [])
msg2 = Message(subject="subject")
msg2.add_recipient("[email protected]")
self.assertEqual(len(msg2.recipients), 1)
示例4: mailer
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def mailer():
msg = Message("client test")
msg.add_recipient("[email protected]")
msg.body = "Yo, shoot me a message"
base_app.mailer.send(msg)
return default_view()
示例5: test_recipients_properly_initialized
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def test_recipients_properly_initialized(self):
msg = Message(subject="subject")
assert msg.recipients == []
msg2 = Message(subject="subject")
msg2.add_recipient("[email protected]")
assert len(msg.recipients) == 0
msg3 = Message(subject="subject")
msg3.add_recipient("[email protected]")
assert len(msg.recipients) == 0
示例6: ajaxtest
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def ajaxtest():
result = {
'success': test(),
}
if not result['success']:
from cron import EMAIL_SENDER
from flaskext.mail import Message
message = Message('Sniper tests are failing', sender=EMAIL_SENDER)
message.body = 'FIX IT'
message.add_recipient('[email protected]')
mail.send(message)
return json.dumps(result)
示例7: notify
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def notify(snipe, index):
""" Notify this snipe that their course is open"""
course = '%s:%s:%s' % (snipe.subject, snipe.course_number, snipe.section)
if snipe.user.email:
attributes = {
'email': snipe.user.email,
'phone_number': snipe.user.phone_number,
'subject': snipe.subject,
'course_number': snipe.course_number,
'section': snipe.section,
}
# build the url for prepopulated form
url = 'http://sniper.vverma.net/?%s' % (urllib.urlencode(attributes))
register_url = 'https://sims.rutgers.edu/webreg/editSchedule.htm?login=cas&semesterSelection=12014&indexList=%s' % (index)
email_text = 'A course (%s) that you were watching looks open. Its index number is %s. Click the link below to register for it!\n\n %s \n\n If you don\'t get in, visit this URL: \n\n %s \n\n to continue watching it.\n\n Send any feedback to [email protected]' % (course, index, register_url, url)
# send out the email
message = Message('[Course Sniper](%s) is open' %(course), sender=EMAIL_SENDER, bcc=["[email protected]"])
message.body = email_text
message.add_recipient(snipe.user.email)
message.add_recipient(snipe.user.email)
mail.send(message)
if snipe.user.phone_number:
# send out a text
try:
text = 'A course (%s) (Index %s) that you were watching looks open. If you don\'t get in, reply back with "%s" and I\'ll continue watching it' % (course, index, course)
message = client.sms.messages.create(to=snipe.user.phone_number, from_="+17326384545", body=text)
except Exception as e:
app.logger.warning('Looks like a phone number is invalid')
db.session.delete(snipe)
db.session.commit()
app.logger.warning('Notified user: %s about snipe %s' % (snipe.user, snipe))
示例8: contact
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def contact(username):
user = User.objects.get_or_404(username=username)
message = {'status': 200}
if request.method == 'POST':
data = request.data
email = json.loads(data)
contact_name = email['name']
contact_email = email['email']
subject = email['subject']
body = email['body']
message = {
'name': {'error': 0 if len(contact_name) else 1, 'value': contact_name},
'email': {'error': 0 if len(contact_email) else 1, 'value': contact_email},
'subject': {'error': 0 if len(subject) else 1, 'value': subject},
'body': {'error': 0 if len(body) else 1, 'value': body},
}
if len(contact_name) == 0 or len(contact_email) == 0 or len(subject) == 0 or len(body) == 0:
message['status'] = 422
resp = jsonify(message)
resp.status_code = 200
return resp
msg = Message(subject, reply_to="%s <%s>"%(contact_name, contact_email))
msg.add_recipient(user.email)
msg.body = body
config.mail.send(msg)
message = {'status': 200, 'message': 'Thanks for your message %s! I will get back to you as soon as posible'%contact_name}
resp = jsonify(message)
resp.status_code = 200
return resp
示例9: test_add_recipient
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def test_add_recipient(self):
msg = Message("testing")
msg.add_recipient("[email protected]")
assert msg.recipients == ["[email protected]"]
示例10: test_add_recipient
# 需要导入模块: from flaskext.mail import Message [as 别名]
# 或者: from flaskext.mail.Message import add_recipient [as 别名]
def test_add_recipient(self):
msg = Message("testing")
msg.add_recipient("[email protected]")
self.assertEqual(msg.recipients, ["[email protected]"])