Ejemplo n.º 1
0
def send_mail(template, subject, emails, context):
    template = loader.get_template(template)
    amo_send_mail(subject,
                  template.render(Context(context, autoescape=False)),
                  recipient_list=emails,
                  from_email=settings.EDITORS_EMAIL,
                  use_blacklist=False)
Ejemplo n.º 2
0
def send_mail(request, template, subject, emails, context, perm_setting=None):
    # Link to our newfangled "Account Settings" page.
    manage_url = absolutify(reverse('account.settings')) + '#notifications'
    amo_send_mail(subject, jingo.render_to_string(request, template, context),
                  recipient_list=emails,
                  from_email=settings.NOBODY_EMAIL,
                  use_blacklist=False, perm_setting=perm_setting,
                  manage_url=manage_url,
                  headers={'Reply-To': settings.MKT_REVIEWERS_EMAIL})
Ejemplo n.º 3
0
def send_mail(template, subject, emails, context):
    template = loader.get_template(template)
    amo_send_mail(
        subject,
        template.render(Context(context, autoescape=False)),
        recipient_list=emails,
        from_email=settings.EDITORS_EMAIL,
        use_blacklist=False,
    )
Ejemplo n.º 4
0
def send_mail(request, template, subject, emails, context, perm_setting=None):
    # Get a jinja environment so we can override autoescaping for text emails.
    env = jingo.get_env()
    env.autoescape = False
    # Link to our newfangled "Account Settings" page.
    manage_url = absolutify(reverse('account.settings')) + '#notifications'
    template = env.get_template(template)
    amo_send_mail(subject, jingo.render_to_string(request, template, context),
                  recipient_list=emails,
                  from_email=settings.NOBODY_EMAIL,
                  use_blacklist=False, perm_setting=perm_setting,
                  manage_url=manage_url,
                  headers={'Reply-To': settings.MKT_REVIEWERS_EMAIL})
Ejemplo n.º 5
0
    def mail_thankyou(self, request=None):
        """
        Mail a thankyou note for a completed contribution.

        Raises a ``ContributionError`` exception when the contribution
        is not complete or email addresses are not found.
        """

        # Setup l10n before loading addon.
        if self.source_locale:
            lang = self.source_locale
        else:
            lang = self.addon.default_locale
        l10n.activate(lang)

        # Thankyous must be enabled.
        if not self.addon.enable_thankyou:
            # Not an error condition, just return.
            return

        # Contribution must be complete.
        if not self.transaction_id:
            raise ContributionError('Transaction not complete')

        # Send from support_email, developer's email, or default.
        if self.addon.support_email:
            from_email = str(self.addon.support_email)
        else:
            try:
                author = self.addon.listed_authors[0]
                if not author.emailhidden:
                    from_email = author.email
            except IndexError:
                from_email = None
        if not from_email:
            from_email = settings.EMAIL_FROM_DEFAULT

        # We need the contributor's email.
        to_email = self.post_data['payer_email']
        if not to_email:
            raise ContributionError('Empty payer email')

        # Make sure the url uses the right language.
        # Setting a prefixer would be nicer, but that requires a request.
        url_parts = self.addon.meet_developers_url.split('/')
        url_parts[1] = lang

        # Buildup the email components.
        t = loader.get_template('stats/contribution-thankyou-email.ltxt')
        c = {
            'thankyou_note': self.addon.thankyou_note,
            'addon_name': self.addon.name,
            'learn_url': settings.SITE_URL + '/'.join(url_parts),
            'hostname': settings.HOSTNAME,
        }
        body = t.render(Context(c))
        subject = _('Thanks for contributing to {addon_name}').format(
                    addon_name=self.addon.name)

        # Send the email
        if amo_send_mail(subject, body, from_email, [to_email],
                     fail_silently=True):
            # Clear out contributor identifying information.
            del(self.post_data['payer_email'])
            self.save()