def send_welcome_email(user_pk, locale): user = get_user_model().objects.get(pk=user_pk) if locale == settings.WIKI_DEFAULT_LANGUAGE or strings_are_translated( WELCOME_EMAIL_STRINGS, locale ): context = {"username": user.username} log.debug("Using the locale %s to send the welcome email", locale) with translation.override(locale): content_plain = render_email("users/email/welcome/plain.ltxt", context) content_html = render_email("users/email/welcome/html.ltxt", context) email = EmailMultiAlternatives( _("Getting started with your new MDN account"), content_plain, config.WELCOME_EMAIL_FROM, [user.email], ) email.attach_alternative(content_html, "text/html") email.send()
def send_welcome_email(user_pk, locale): user = get_user_model().objects.get(pk=user_pk) if (locale == settings.WIKI_DEFAULT_LANGUAGE or strings_are_translated(WELCOME_EMAIL_STRINGS, locale)): context = {'username': user.username} log.debug('Using the locale %s to send the welcome email', locale) with uselocale(locale): content_plain = render_to_string('users/email/welcome/plain.ltxt', context) content_html = render_to_string('users/email/welcome/html.ltxt', context) email = EmailMultiAlternatives( _('Take the next step to get involved on MDN!'), content_plain, config.WELCOME_EMAIL_FROM, [user.email], ) email.attach_alternative(content_html, 'text/html') email.send()