How to use the sumo.email_utils.send_messages function in sumo

To help you get started, we’ve selected a few sumo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / kitsune / apps / users / views.py View on Github external
group = Group.objects.get(name=CONTRIBUTOR_GROUP)
    request.user.groups.add(group)

    @email_utils.safe_translation
    def _make_mail(locale):
        mail = email_utils.make_mail(
            subject=_('Welcome to SUMO!'),
            text_template='users/email/contributor.ltxt',
            html_template='users/email/contributor.html',
            context_vars={'username': request.user.username},
            from_email=settings.DEFAULT_FROM_EMAIL,
            to_email=request.user.email)

        return mail

    email_utils.send_messages([_make_mail(request.LANGUAGE_CODE)])

    if 'return_to' in request.POST:
        return HttpResponseRedirect(request.POST['return_to'])
    else:
        return HttpResponseRedirect(reverse('landings.get_involved'))
github mozilla / kitsune / apps / users / models.py View on Github external
else:
            locale = confirmation_profile.user.profile.locale

        @email_utils.safe_translation
        def _make_mail(locale):
            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=email_kwargs,
                from_email=settings.DEFAULT_FROM_EMAIL,
                to_email=send_to)

            return mail

        email_utils.send_messages([_make_mail(locale)])
github mozilla / kitsune / apps / users / forms.py View on Github external
def _send_mail(locale, user, context):
            subject = _('Your username on %s') % site_name

            mail = email_utils.make_mail(
                subject=subject,
                text_template=text_template,
                html_template=html_template,
                context_vars=context,
                from_email=settings.TIDINGS_FROM_ADDRESS,
                to_email=user.email)

            email_utils.send_messages([mail])
github mozilla / kitsune / apps / users / forms.py View on Github external
mail = email_utils.make_mail(
                    subject=subject,
                    text_template=text_template,
                    html_template=html_template,
                    context_vars=c,
                    from_email=from_email,
                    to_email=user.email)

                return mail

            if request:
                locale = request.LANGUAGE_CODE
            else:
                locale = settings.WIKI_DEFAULT_LANGUAGE

            email_utils.send_messages([_make_mail(locale)])
github mozilla / kitsune / apps / users / views.py View on Github external
subject = _('Account already activated')

                    @email_utils.safe_translation
                    def _make_mail(locale):
                        mail = email_utils.make_mail(
                            subject=subject,
                            text_template='users/email/already_activated.ltxt',
                            html_template='users/email/already_activated.html',
                            context_vars=email_kwargs,
                            from_email=settings.DEFAULT_FROM_EMAIL,
                            to_email=user.email)

                        return mail

                    email_utils.send_messages(
                        [_make_mail(request.LANGUAGE_CODE)])
                except User.DoesNotExist:
                    # Don't leak existence of email addresses.
                    pass
            # Form may now be invalid if email failed to send.
            if form.is_valid():
                return render(
                    request, template + 'resend_confirmation_done.html',
                    {'email': email})
    else:
        form = EmailConfirmationForm()
    return render(request, template + 'resend_confirmation.html', {
        'form': form})
github mozilla / kitsune / apps / wiki / tasks.py View on Github external
for r in based_on:
        # Send email to all contributors except the reviewer and the creator
        # of the approved revision.
        if r.creator in [revision.creator, revision.reviewer]:
            continue

        user = r.creator

        if hasattr(user, 'profile'):
            locale = user.profile.locale
        else:
            locale = settings.WIKI_DEFAULT_LANGUAGE

        _make_mail(locale, user)

    email_utils.send_messages(msgs)
github mozilla / kitsune / apps / messages / tasks.py View on Github external
'sender': inbox_message.sender.username,
            'message': inbox_message.message,
            'message_html': inbox_message.content_parsed,
            'message_url': reverse('messages.read',
                                   kwargs={'msgid': inbox_message.id}),
            'unsubscribe_url': reverse('users.edit_settings'),
            'host': Site.objects.get_current().domain}

        mail = make_mail(subject=subject,
                         text_template='messages/email/private_message.ltxt',
                         html_template='messages/email/private_message.html',
                         context_vars=context,
                         from_email=settings.TIDINGS_FROM_ADDRESS,
                         to_email=inbox_message.to.email)

        send_messages([mail])