当前位置: 首页>>代码示例>>Python>>正文


Python mail.send_mail函数代码示例

本文整理汇总了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)
开发者ID:Jobava,项目名称:zamboni,代码行数:26,代码来源:models.py

示例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]'])
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:8,代码来源:test_mail.py

示例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,))
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:13,代码来源:models.py

示例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)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:7,代码来源:test_mail.py

示例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)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:7,代码来源:test_mail.py

示例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])
开发者ID:gurumukhi,项目名称:zamboni,代码行数:8,代码来源:test_mail.py

示例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])
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:9,代码来源:test_mail.py

示例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])
开发者ID:j-barron,项目名称:zamboni,代码行数:10,代码来源:test_mail.py

示例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)
开发者ID:gurumukhi,项目名称:zamboni,代码行数:13,代码来源:test_mail.py

示例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)
开发者ID:gurumukhi,项目名称:zamboni,代码行数:13,代码来源:test_mail.py

示例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
开发者ID:gurumukhi,项目名称:zamboni,代码行数:14,代码来源:test_mail.py

示例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)
开发者ID:gurumukhi,项目名称:zamboni,代码行数:15,代码来源:test_mail.py

示例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
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:15,代码来源:test_mail.py

示例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)
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:5,代码来源:models.py

示例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")
开发者ID:gurumukhi,项目名称:zamboni,代码行数:3,代码来源:test_mail.py


注:本文中的mkt.site.mail.send_mail函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。