本文整理汇总了Python中mkt.site.mail.send_mail函数的典型用法代码示例。如果您正苦于以下问题:Python send_mail函数的具体用法?Python send_mail怎么用?Python send_mail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_mail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send
def send(self):
obj = self.object
if self.reporter:
user_name = '%s (%s)' % (self.reporter.name, self.reporter.email)
else:
user_name = 'An anonymous coward'
if self.website:
# For Websites, it's not just abuse, the scope is broader, it could
# be any issue about the website listing itself, so use a different
# wording and recipient list.
type_ = u'Website'
subject = u'[%s] Issue Report for %s' % (type_, obj.name)
recipient_list = (settings.MKT_FEEDBACK_EMAIL,)
else:
if self.addon:
type_ = 'App'
elif self.user:
type_ = 'User'
subject = u'[%s] Abuse Report for %s' % (type_, obj.name)
recipient_list = (settings.ABUSE_EMAIL,)
msg = u'%s reported an issue for %s (%s%s).\n\n%s' % (
user_name, obj.name, settings.SITE_URL, obj.get_url_path(),
self.message)
send_mail(subject, msg, recipient_list=recipient_list)
示例2: test_async_will_stop_retrying
def test_async_will_stop_retrying(self, backend):
backend.side_effect = self.make_backend_class([True, True])
with self.assertRaises(RuntimeError):
send_mail('test subject',
'test body',
async=True,
max_retries=1,
recipient_list=['[email protected]'])
示例3: send
def send(self):
obj = self.addon or self.user
if self.reporter:
user_name = '%s (%s)' % (self.reporter.name, self.reporter.email)
else:
user_name = 'An anonymous coward'
type_ = ('App' if self.addon else 'User')
subject = u'[%s] Abuse Report for %s' % (type_, obj.name)
msg = u'%s reported abuse for %s (%s%s).\n\n%s' % (
user_name, obj.name, settings.SITE_URL, obj.get_url_path(),
self.message)
send_mail(subject, msg, recipient_list=(settings.ABUSE_EMAIL,))
示例4: test_success_fake_mail
def test_success_fake_mail(self):
assert send_mail('test subject', 'test body',
recipient_list=['[email protected]'],
fail_silently=False)
eq_(len(mail.outbox), 0)
eq_(FakeEmail.objects.count(), 1)
eq_(FakeEmail.objects.get().message.endswith('test body'), True)
示例5: test_success_real_mail
def test_success_real_mail(self):
assert send_mail('test subject', 'test body',
recipient_list=['[email protected]'],
fail_silently=False)
eq_(len(mail.outbox), 1)
eq_(mail.outbox[0].subject.find('test subject'), 0)
eq_(mail.outbox[0].body.find('test body'), 0)
示例6: test_blacklist
def test_blacklist(self):
to = "[email protected]"
to2 = "[email protected]"
settings.EMAIL_BLACKLIST = (to,)
success = send_mail("test subject", "test body", recipient_list=[to, to2], fail_silently=False)
assert success
eq_(len(mail.outbox), 1)
eq_(mail.outbox[0].to, [to2])
示例7: test_blocked
def test_blocked(self):
to = '[email protected]'
to2 = '[email protected]'
settings.EMAIL_BLOCKED = (to,)
success = send_mail('test subject', 'test body',
recipient_list=[to, to2], fail_silently=False)
assert success
eq_(len(mail.outbox), 1)
eq_(mail.outbox[0].to, [to2])
示例8: test_blacklist_flag
def test_blacklist_flag(self):
to = '[email protected]'
to2 = '[email protected]'
settings.EMAIL_BLACKLIST = (to,)
success = send_mail('test subject', 'test body',
recipient_list=[to, to2], fail_silently=False,
use_blacklist=True)
assert success
eq_(len(mail.outbox), 1)
eq_(mail.outbox[0].to, [to2])
示例9: test_user_setting_checked
def test_user_setting_checked(self):
user = UserProfile.objects.all()[0]
to = user.email
n = mkt.users.notifications.NOTIFICATIONS_BY_SHORT["reply"]
UserNotification.objects.get_or_create(notification_id=n.id, user=user, enabled=True)
# Confirm we're reading from the database
eq_(UserNotification.objects.filter(notification_id=n.id).count(), 1)
success = send_mail("test subject", "test body", perm_setting="reply", recipient_list=[to], fail_silently=False)
assert success, "Email wasn't sent"
eq_(len(mail.outbox), 1)
示例10: test_user_mandatory
def test_user_mandatory(self):
user = UserProfile.objects.all()[0]
to = user.email
n = mkt.users.notifications.NOTIFICATIONS_BY_SHORT["individual_contact"]
UserNotification.objects.get_or_create(notification_id=n.id, user=user, enabled=True)
assert n.mandatory, "Notification isn't mandatory"
success = send_mail("test subject", "test body", perm_setting=n, recipient_list=[to], fail_silently=False)
assert success, "Email wasn't sent"
eq_(len(mail.outbox), 1)
示例11: test_real_list
def test_real_list(self):
to = "[email protected]"
to2 = "[email protected]mozilla.org"
to3 = "[email protected]"
set_config("real_email_whitelist", to3)
success = send_mail("test subject", "test_real_list", recipient_list=[to, to2, to3], fail_silently=False)
assert success
eq_(len(mail.outbox), 1)
eq_(mail.outbox[0].to, [to3])
assert "test_real_list" in mail.outbox[0].body
eq_(FakeEmail.objects.count(), 1) # Only one mail, two recipients.
fakeemail = FakeEmail.objects.get()
eq_(fakeemail.message.endswith("test_real_list"), True)
assert ("To: %s, %s" % (to, to2)) in fakeemail.message
示例12: test_user_setting_default
def test_user_setting_default(self):
user = UserProfile.objects.all()[0]
to = user.email
# Confirm there's nothing in the DB and we're using the default
eq_(UserNotification.objects.count(), 0)
# Make sure that this is True by default
setting = mkt.users.notifications.NOTIFICATIONS_BY_SHORT["reply"]
eq_(setting.default_checked, True)
success = send_mail("test subject", "test body", perm_setting="reply", recipient_list=[to], fail_silently=False)
assert success, "Email wasn't sent"
eq_(len(mail.outbox), 1)
示例13: test_real_list
def test_real_list(self):
to = '[email protected]'
to2 = '[email protected]'
to3 = '[email protected]'
set_config('real_email_whitelist', to3)
success = send_mail('test subject', 'test_real_list',
recipient_list=[to, to2, to3], fail_silently=False)
assert success
eq_(len(mail.outbox), 1)
eq_(mail.outbox[0].to, [to3])
assert 'test_real_list' in mail.outbox[0].body
eq_(FakeEmail.objects.count(), 1) # Only one mail, two recipients.
fakeemail = FakeEmail.objects.get()
eq_(fakeemail.message.endswith('test_real_list'), True)
assert ('To: %s, %s' % (to, to2)) in fakeemail.message
示例14: _mail
def _mail(self, template, subject, context):
template = env.get_template(template)
body = template.render(context)
send_mail(subject, body, settings.MARKETPLACE_EMAIL,
[self.user.email], fail_silently=True)
示例15: test_send_multilines_subjects
def test_send_multilines_subjects(self):
send_mail("test\nsubject", "test body", from_email="[email protected]", recipient_list=["[email protected]"])
eq_("test subject", mail.outbox[0].subject, "Subject not stripped")