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


Python MessageBuilder.send方法代码示例

本文整理汇总了Python中sentry.utils.email.MessageBuilder.send方法的典型用法代码示例。如果您正苦于以下问题:Python MessageBuilder.send方法的具体用法?Python MessageBuilder.send怎么用?Python MessageBuilder.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sentry.utils.email.MessageBuilder的用法示例。


在下文中一共展示了MessageBuilder.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_add_groupemailthread

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def test_add_groupemailthread(self, make_msgid):
        make_msgid.return_value = 'abc123'

        msg = MessageBuilder(
            subject='Test',
            body='hello world',
            html_body='<b>hello world</b>',
            reference=self.group,
        )
        msg.send(['[email protected]'])

        assert len(mail.outbox) == 1

        out = mail.outbox[0]
        assert out.to == ['[email protected]']
        assert out.subject == 'Test', 'First message should not have Re: prefix'
        assert out.extra_headers['Message-Id'] == 'abc123'
        assert 'In-Reply-To' not in out.extra_headers
        assert 'References' not in out.extra_headers
        assert out.body == 'hello world'
        assert len(out.alternatives) == 1
        assert out.alternatives[0] == (
            '<!DOCTYPE html>\n<html><body><b>hello world</b></body></html>', 'text/html',
        )

        # Our new EmailThread row was added
        assert GroupEmailThread.objects.count() == 1
        thread = GroupEmailThread.objects.all()[0]
        assert thread.msgid == 'abc123'
        assert thread.email == '[email protected]'
        assert thread.group == self.group
开发者ID:Kayle009,项目名称:sentry,代码行数:33,代码来源:tests.py

示例2: test_fake_dont_send

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def test_fake_dont_send(self):
        project = self.project

        user_a = User.objects.create(email=create_fake_email('foo', 'fake'))
        user_b = User.objects.create(email=create_fake_email('bar', 'fake'))
        user_c = User.objects.create(email=create_fake_email('baz', 'fake'))

        UserOption.objects.create(
            user=user_b,
            key='alert_email',
            value=create_fake_email('fizzle', 'fake'),
        )
        UserOption.objects.create(
            user=user_c,
            project=project,
            key='mail:email',
            value=create_fake_email('bazzer', 'fake'),
        )

        msg = MessageBuilder(
            subject='Test',
            body='hello world',
            html_body='<!DOCTYPE html>\n<b>hello world</b>',
        )
        msg.add_users([user_a.id, user_b.id, user_c.id], project=project)
        msg.send()

        assert len(mail.outbox) == 0
开发者ID:Kayle009,项目名称:sentry,代码行数:30,代码来源:tests.py

示例3: send_approved_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def send_approved_email(self):
        from sentry.utils.email import MessageBuilder

        user = self.member.user
        email = user.email
        organization = self.team.organization

        context = {
            'email': email,
            'name': user.get_display_name(),
            'organization': organization,
            'team': self.team,
        }

        msg = MessageBuilder(
            subject='Sentry Access Request',
            template='sentry/emails/access-approved.txt',
            html_template='sentry/emails/access-approved.html',
            context=context,
        )

        try:
            msg.send([email])
        except Exception as e:
            logger = logging.getLogger('sentry.mail.errors')
            logger.exception(e)
开发者ID:ChadKillingsworth,项目名称:sentry,代码行数:28,代码来源:organizationaccessrequest.py

示例4: send_request_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def send_request_email(self):
        from sentry.utils.email import MessageBuilder

        user = self.member.user
        email = user.email
        organization = self.team.organization

        context = {
            'email': email,
            'name': user.get_display_name(),
            'organization': organization,
            'team': self.team,
            'url': absolute_uri(reverse('sentry-organization-members', kwargs={
                'organization_slug': organization.slug,
            }) + '?ref=access-requests'),
        }

        msg = MessageBuilder(
            subject='Sentry Access Request',
            template='sentry/emails/request-team-access.txt',
            html_template='sentry/emails/request-team-access.html',
            context=context,
        )

        try:
            msg.send([email])
        except Exception as e:
            logger = logging.getLogger('sentry.mail.errors')
            logger.exception(e)
开发者ID:ChadKillingsworth,项目名称:sentry,代码行数:31,代码来源:organizationaccessrequest.py

示例5: test_with_users

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def test_with_users(self):
        project = self.project

        user_a = User.objects.create(email='[email protected]')
        user_b = User.objects.create(email='[email protected]')
        user_c = User.objects.create(email='[email protected]')

        UserOption.objects.create(
            user=user_b,
            key='alert_email',
            value='[email protected]',
        )
        UserOption.objects.create(
            user=user_c,
            project=project,
            key='mail:email',
            value='[email protected]',
        )

        msg = MessageBuilder(
            subject='Test',
            body='hello world',
            html_body='<!DOCTYPE html>\n<b>hello world</b>',
        )
        msg.add_users([user_a.id, user_b.id, user_c.id], project=project)
        msg.send()

        assert len(mail.outbox) == 3

        assert sorted([out.to[0] for out in mail.outbox]) == [
            '[email protected]',
            '[email protected]',
            '[email protected]',
        ]
开发者ID:Kayle009,项目名称:sentry,代码行数:36,代码来源:tests.py

示例6: test_reply_reference

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def test_reply_reference(self, make_msgid):
        make_msgid.return_value = 'abc123'

        msg = MessageBuilder(
            subject='Test',
            body='hello world',
            html_body='<b>hello world</b>',
            reference=self.activity,
            reply_reference=self.group,
        )
        msg.send(['[email protected]'])

        assert len(mail.outbox) == 1

        out = mail.outbox[0]
        assert out.to == ['[email protected]']
        assert out.subject == 'Re: Test'
        assert out.extra_headers['Message-Id'] == 'abc123'
        assert 'In-Reply-To' not in out.extra_headers
        assert 'References' not in out.extra_headers
        assert out.body == 'hello world'
        assert len(out.alternatives) == 1
        assert out.alternatives[0] == (
            '<!DOCTYPE html>\n<html><body><b>hello world</b></body></html>',
            'text/html',
        )

        # Our new EmailThread row was added
        assert GroupEmailThread.objects.count() == 1
        thread = GroupEmailThread.objects.all()[0]
        assert thread.msgid == 'abc123'
        assert thread.email == '[email protected]'
        assert thread.group == self.group

        # new msgid for the next message
        make_msgid.return_value = '321cba'
        msg.send(['[email protected]'])

        assert len(mail.outbox) == 2

        out = mail.outbox[1]
        assert out.to == ['[email protected]']
        assert out.subject == 'Re: Test'
        assert out.extra_headers['Message-Id'] == '321cba'
        assert out.extra_headers['In-Reply-To'] == 'abc123'
        assert out.extra_headers['References'] == 'abc123'
        assert out.body == 'hello world'
        assert len(out.alternatives) == 1
        assert out.alternatives[0] == (
            '<!DOCTYPE html>\n<html><body><b>hello world</b></body></html>',
            'text/html',
        )

        # Our new GroupEmailThread row was added
        assert GroupEmailThread.objects.count() == 1, 'Should not have added a new row'
        assert GroupEmailThread.objects.all()[0].msgid == 'abc123', 'msgid should not have changed'
开发者ID:duanshuaimin,项目名称:sentry,代码行数:58,代码来源:tests.py

示例7: test_stripped_newline

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def test_stripped_newline(self):
        msg = MessageBuilder(
            subject='Foo\r\nBar',
            body='hello world',
            html_body='<b>hello world</b',
        )
        msg.send(['[email protected]'])

        assert len(mail.outbox) == 1
        assert mail.outbox[0].subject == 'Foo'
开发者ID:Kayle009,项目名称:sentry,代码行数:12,代码来源:tests.py

示例8: test_bcc_on_send

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def test_bcc_on_send(self):
        msg = MessageBuilder(
            subject='Test',
            body='hello world',
        )
        msg.send(['[email protected]'], bcc=['[email protected]'])

        assert len(mail.outbox) == 1

        out = mail.outbox[0]
        assert out.to == ['[email protected]']
        assert out.bcc == ['[email protected]ple.com']
开发者ID:Kayle009,项目名称:sentry,代码行数:14,代码来源:tests.py

示例9: _send_mail

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def _send_mail(self, subject, body, html_body=None, project=None,
                   headers=None, fail_silently=False):
        send_to = self.get_send_to(project)
        if not send_to:
            return

        subject_prefix = self.get_option('subject_prefix', project) or self.subject_prefix

        msg = MessageBuilder(
            subject='%s%s' % (subject_prefix, subject),
            body=body,
            html_body=html_body,
            headers=headers,
        )
        msg.send(send_to, fail_silently=fail_silently)
开发者ID:XuYong,项目名称:sentry,代码行数:17,代码来源:models.py

示例10: _send_mail

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def _send_mail(
        self,
        subject,
        template=None,
        html_template=None,
        body=None,
        project=None,
        headers=None,
        context=None,
        fail_silently=False,
    ):

        subject_prefix = self.get_option("subject_prefix", project) or self.subject_prefix

        msg = MessageBuilder(
            subject="%s%s" % (subject_prefix, subject),
            template=template,
            html_template=html_template,
            body=body,
            headers=headers,
            context=context,
        )

        send_to = self._send_to

        return msg.send(to=send_to, fail_silently=fail_silently)
开发者ID:rogerhu,项目名称:sentry-subscriptions,代码行数:28,代码来源:plugin.py

示例11: _send_mail

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def _send_mail(self, subject, template=None, html_template=None, body=None,
                   project=None, group=None, headers=None, context=None,
                   fail_silently=False):
        send_to = self.get_send_to(project)
        if not send_to:
            return

        subject_prefix = self.get_option('subject_prefix', project) or self.subject_prefix

        try:
            subject_prefix = subject_prefix.encode("utf-8")
            subject = subject.encode("utf-8")
        except UnicodeDecodeError:
            subject_prefix = unicode(subject_prefix, "utf-8")
            subject = unicode(subject, "utf-8")

        msg = MessageBuilder(
            subject='%s%s' % (subject_prefix, subject),
            template=template,
            html_template=html_template,
            body=body,
            headers=headers,
            context=context,
            reference=group,
        )
        msg.add_users(send_to, project=project)
        return msg.send(fail_silently=fail_silently)
开发者ID:erhuabushuo,项目名称:sentry,代码行数:29,代码来源:models.py

示例12: send_notification

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def send_notification(self):
        from sentry.utils.email import MessageBuilder

        if self.type != Activity.NOTE or not self.group:
            return

        user_list = list(User.objects.filter(
            groupseen__group=self.group,
        ).exclude(user=self.user))
        disabled = set(UserOption.objects.filter(
            user__in=user_list, key='subscribe_comments', value='0'))

        send_to = [
            u.email for u in user_list
            if u.id not in disabled
            and u.email
        ]

        author = self.user.first_name or self.user.username

        subject = '%s: %s' % (
            author,
            self.data['text'].splitlines()[0][:64])

        context = {
            'text': self.data['text'],
            'author': author,
            'group': self.group,
            'link': self.group.get_absolute_url(),
        }

        msg = MessageBuilder(
            subject=subject,
            context=context,
            template='sentry/emails/new_note.txt',
            html_template='sentry/emails/new_note.html',
        )

        try:
            msg.send(to=send_to)
        except Exception, e:
            logger = logging.getLogger('sentry.mail.errors')
            logger.exception(e)
开发者ID:russelldavis,项目名称:sentry,代码行数:45,代码来源:models.py

示例13: test_explicit_reply_to

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def test_explicit_reply_to(self):
        msg = MessageBuilder(
            subject='Test',
            body='hello world',
            html_body='<b>hello world</b>',
            headers={'X-Sentry-Reply-To': '[email protected]'},
        )
        msg.send(['[email protected]'])

        assert len(mail.outbox) == 1

        out = mail.outbox[0]
        assert out.to == ['[email protected]']
        assert out.subject == 'Test'
        assert out.extra_headers['Reply-To'] == '[email protected]'
        assert out.body == 'hello world'
        assert len(out.alternatives) == 1
        assert out.alternatives[0] == (
            '<!DOCTYPE html>\n<html><body><b>hello world</b></body></html>', 'text/html',
        )
开发者ID:Kayle009,项目名称:sentry,代码行数:22,代码来源:tests.py

示例14: test_raw_content

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def test_raw_content(self):
        msg = MessageBuilder(
            subject='Test',
            body='hello world',
            html_body='<b>hello world</b>',
            headers={'X-Test': 'foo'},
        )
        msg.send(['[email protected]'])

        assert len(mail.outbox) == 1

        out = mail.outbox[0]
        assert out.to == ['[email protected]']
        assert out.subject == 'Test'
        assert out.extra_headers['X-Test'] == 'foo'
        assert out.body == 'hello world'
        assert len(out.alternatives) == 1
        assert out.alternatives[0] == (
            '<!DOCTYPE html>\n<html><body><b>hello world</b></body></html>', 'text/html',
        )
开发者ID:Kayle009,项目名称:sentry,代码行数:22,代码来源:tests.py

示例15: send_invite_email

# 需要导入模块: from sentry.utils.email import MessageBuilder [as 别名]
# 或者: from sentry.utils.email.MessageBuilder import send [as 别名]
    def send_invite_email(self):
        from sentry.utils.email import MessageBuilder

        context = {
            "email": self.email,
            "team": self.team,
            "url": absolute_uri(reverse("sentry-accept-invite", kwargs={"member_id": self.id, "token": self.token})),
        }

        msg = MessageBuilder(
            subject="Invite to join team: %s" % (self.team.name,),
            template="sentry/emails/member_invite.txt",
            context=context,
        )

        try:
            msg.send([self.email])
        except Exception, e:
            logger = logging.getLogger("sentry.mail.errors")
            logger.exception(e)
开发者ID:beyondtime,项目名称:sentry,代码行数:22,代码来源:pendingteammember.py


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