• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mail.send_mail函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.site.mail.send_mail函数的典型用法代码示例。如果您正苦于以下问题:Python send_mail函数的具体用法?Python send_mail怎么用?Python send_mail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了send_mail函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: test_async_will_retry

 def test_async_will_retry(self, backend):
     backend.side_effect = self.make_backend_class([True, True, False])
     with self.assertRaises(RuntimeError):
         send_mail("test subject", "test body", recipient_list=["[email protected]"])
     assert send_mail("test subject", "test body", async=True, recipient_list=["[email protected]"])
开发者ID:gurumukhi,项目名称:zamboni,代码行数:5,代码来源:test_mail.py


示例17: _review


#.........这里部分代码省略.........

            if appfeatures_form.changed_data:
                # The reviewer overrode the requirements. We need to not
                # publish this app immediately.
                if addon.publish_type == mkt.PUBLISH_IMMEDIATE:
                    addon.update(publish_type=mkt.PUBLISH_PRIVATE)

                appfeatures_form.save(mark_for_rereview=False)

                # Log that the reviewer changed the minimum requirements.
                added_features, removed_features = (appfeatures_form
                                                    .get_changed_features())

                fmt = ', '.join(
                      [_(u'Added {0}').format(f) for f in added_features] +
                      [_(u'Removed {0}').format(f) for f in removed_features])
                # L10n: {0} is the list of requirements changes.
                msg = _(u'Requirements changed by reviewer: {0}').format(fmt)

                log_reviewer_action(addon, request.user, msg,
                                    mkt.LOG.REVIEW_FEATURES_OVERRIDE)

        score = form.helper.process()

        if form.cleaned_data.get('is_showcase'):
            if not addon.tags.filter(tag_text=SHOWCASE_TAG).exists():
                Tag(tag_text=SHOWCASE_TAG).save_tag(addon)
                recipient_list = (settings.APP_CURATION_BOARD_EMAIL,)
                subject = u'App [%s] nominated to be featured' % addon.name
                msg = (u'The Marketplace reviewer %s thinks %s (%s%s) is'
                       u'good enough to be a featured app.\n\n' % (
                           request.user, addon.name, settings.SITE_URL,
                           addon.get_url_path()))
                send_mail(subject, msg, recipient_list=recipient_list)
        else:
            Tag(tag_text=SHOWCASE_TAG).remove_tag(addon)

        # Success message.
        if score:
            score = ReviewerScore.objects.filter(user=request.user)[0]
            # L10N: {0} is the type of review. {1} is the points they earned.
            #       {2} is the points they now have total.
            success = _(
                u'"{0}" successfully processed (+{1} points, {2} total).'
                .format(unicode(mkt.REVIEWED_CHOICES[score.note_key]),
                        score.score,
                        ReviewerScore.get_total(request.user)))
        else:
            success = _('Review successfully processed.')
        messages.success(request, success)

        return redirect(redirect_url)

    canned = CannedResponse.objects.all()
    actions = form.helper.actions.items()

    try:
        if not version:
            raise Version.DoesNotExist
        show_diff = (addon.versions.exclude(id=version.id)
                                   .filter(files__isnull=False,
                                           created__lt=version.created,
                                           files__status=mkt.STATUS_PUBLIC)
                                   .latest())
    except Version.DoesNotExist:
        show_diff = None
开发者ID:carriercomm,项目名称:zamboni,代码行数:67,代码来源:views.py


示例18: test_send_string

 def test_send_string(self):
     to = "[email protected]"
     with self.assertRaises(ValueError):
         send_mail("subj", "body", recipient_list=to)
开发者ID:gurumukhi,项目名称:zamboni,代码行数:4,代码来源:test_mail.py


示例19: 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:Fjoerfoks,项目名称:zamboni,代码行数:4,代码来源:test_mail.py


示例20: 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:gurumukhi,项目名称:zamboni,代码行数:5,代码来源:test_mail.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mail.send_mail_jinja函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.product_as_dict函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap