Example #1
0
def send_purchase_receipt(contrib_id, **kw):
    """
    Sends an email to the purchaser of the app.
    """
    contrib = Contribution.objects.get(pk=contrib_id)

    with contrib.user.activate_lang():
        addon = contrib.addon
        version = addon.current_version or addon.latest_version
        # L10n: {0} is the app name.
        subject = _('Receipt for {0}').format(contrib.addon.name)
        data = {
            'app_name': addon.name,
            'developer_name': version.developer_name if version else '',
            'price': contrib.get_amount_locale(get_locale_from_lang(
                contrib.source_locale)),
            'date': jingo.helpers.datetime(contrib.created.date()),
            'purchaser_email': contrib.user.email,
            #'purchaser_phone': '',  # TODO: See bug 894614.
            #'purchaser_last_four': '',
            'transaction_id': contrib.uuid,
            'purchases_url': absolutify('/purchases'),
            'support_url': addon.support_url,
            'terms_of_service_url': absolutify('/terms-of-use'),
        }

        log.info('Sending email about purchase: %s' % contrib_id)
        text_template = 'purchase/receipt.ltxt'
        html_template = 'purchase/receipt.html'
        send_html_mail_jinja(subject, html_template, text_template, data,
                             recipient_list=[contrib.user.email])
Example #2
0
    def test_send_html_mail_jinja(self):
        emails = ['*****@*****.**']
        subject = u'Test'
        html_template = 'purchase/receipt.html'
        text_template = 'purchase/receipt.ltxt'
        send_html_mail_jinja(
            subject, html_template, text_template,
            context={}, recipient_list=emails,
            from_email=settings.NOBODY_EMAIL,
            use_blocked=False,
            perm_setting='individual_contact',
            headers={'Reply-To': settings.MKT_REVIEWERS_EMAIL})

        msg = mail.outbox[0]
        message = msg.message()

        eq_(msg.to, emails)
        eq_(msg.subject, subject)
        eq_(msg.from_email, settings.NOBODY_EMAIL)
        eq_(msg.extra_headers['Reply-To'], settings.MKT_REVIEWERS_EMAIL)

        eq_(message.is_multipart(), True)
        eq_(message.get_content_type(), 'multipart/alternative')
        eq_(message.get_default_type(), 'text/plain')

        payload = message.get_payload()
        eq_(payload[0].get_content_type(), 'text/plain')
        eq_(payload[1].get_content_type(), 'text/html')

        message1 = payload[0].as_string()
        message2 = payload[1].as_string()

        assert '<A HREF' not in message1, 'text-only email contained HTML!'
        assert '<A HREF' in message2, 'HTML email did not contain HTML!'
Example #3
0
    def test_send_html_mail_jinja(self):
        emails = ['*****@*****.**']
        subject = u'Test'
        html_template = 'purchase/receipt.html'
        text_template = 'purchase/receipt.ltxt'
        send_html_mail_jinja(subject, html_template, text_template,
                             context={}, recipient_list=emails,
                             from_email=settings.NOBODY_EMAIL,
                             use_blacklist=False,
                             perm_setting='individual_contact',
                             headers={'Reply-To': settings.MKT_REVIEWERS_EMAIL})

        msg = mail.outbox[0]
        message = msg.message()

        eq_(msg.to, emails)
        eq_(msg.subject, subject)
        eq_(msg.from_email, settings.NOBODY_EMAIL)
        eq_(msg.extra_headers['Reply-To'], settings.MKT_REVIEWERS_EMAIL)

        eq_(message.is_multipart(), True)
        eq_(message.get_content_type(), 'multipart/alternative')
        eq_(message.get_default_type(), 'text/plain')

        payload = message.get_payload()
        eq_(payload[0].get_content_type(), 'text/plain')
        eq_(payload[1].get_content_type(), 'text/html')

        message1 = payload[0].as_string()
        message2 = payload[1].as_string()

        assert '<A HREF' not in message1, 'text-only email contained HTML!'
        assert '<A HREF' in message2, 'HTML email did not contain HTML!'
Example #4
0
def send_purchase_receipt(contrib_id, **kw):
    """
    Sends an email to the purchaser of the app.
    """
    contrib = Contribution.objects.get(pk=contrib_id)

    with contrib.user.activate_lang():
        addon = contrib.addon
        version = addon.current_version or addon.latest_version
        # L10n: {0} is the app name.
        subject = _('Receipt for {0}').format(contrib.addon.name)
        data = {
            'app_name': addon.name,
            'developer_name': version.developer_name if version else '',
            'price': contrib.get_amount_locale(get_locale_from_lang(
                contrib.source_locale)),
            'date': jingo.helpers.datetime(contrib.created.date()),
            'purchaser_email': contrib.user.email,
            #'purchaser_phone': '',  # TODO: See bug 894614.
            #'purchaser_last_four': '',
            'transaction_id': contrib.uuid,
            'purchases_url': absolutify('/purchases'),
            'support_url': addon.support_url,
            'terms_of_service_url': absolutify('/terms-of-use'),
        }

        log.info('Sending email about purchase: %s' % contrib_id)
        text_template = 'purchase/receipt.ltxt'
        html_template = 'purchase/receipt.html'
        send_html_mail_jinja(subject, html_template, text_template, data,
                             recipient_list=[contrib.user.email])
Example #5
0
def send_mail(user_ids, subject, html_template, text_template, link):
    for user in UserProfile.objects.filter(pk__in=user_ids):
        if not user.email:
            log.info('Skipping: {0}, no email'.format(user.pk))
            continue

        context = {'title': subject}
        if link:
            context['link'] = fxa_preverify_url(user, timedelta(days=7))

        with user.activate_lang():
            log.info('Sending FxA transition email to: {0} (id={1})'
                     .format(user.email, user.pk))
            send_html_mail_jinja(
                force_text(subject),
                html_template, text_template,
                context, recipient_list=[user.email])
Example #6
0
    def test_send_html_mail_jinja(self):
        emails = ["*****@*****.**"]
        subject = u"Test"
        html_template = "purchase/receipt.html"
        text_template = "purchase/receipt.ltxt"
        send_html_mail_jinja(
            subject,
            html_template,
            text_template,
            context={},
            recipient_list=emails,
            from_email=settings.NOBODY_EMAIL,
            use_blacklist=False,
            perm_setting="individual_contact",
            headers={"Reply-To": settings.EDITORS_EMAIL},
        )

        msg = mail.outbox[0]
        message = msg.message()

        eq_(msg.to, emails)
        eq_(msg.subject, subject)
        eq_(msg.from_email, settings.NOBODY_EMAIL)
        eq_(msg.extra_headers["Reply-To"], settings.EDITORS_EMAIL)

        eq_(message.is_multipart(), True)
        eq_(message.get_content_type(), "multipart/alternative")
        eq_(message.get_default_type(), "text/plain")

        payload = message.get_payload()
        eq_(payload[0].get_content_type(), "text/plain")
        eq_(payload[1].get_content_type(), "text/html")

        message1 = payload[0].as_string()
        message2 = payload[1].as_string()

        assert "<A HREF" not in message1, "text-only email contained HTML!"
        assert "<A HREF" in message2, "HTML email did not contain HTML!"