Commit f655f780ad0b1e9908c744eb279e79f61c05e633

Authored by Sergio Oliveira
1 parent 41ac22fb

helpers to send verification emails

Showing 1 changed file with 19 additions and 0 deletions   Show diff stats
src/super_archives/utils.py 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +
  2 +from django.core import mail
  3 +from django.conf import settings
  4 +from django.template import Context, loader
  5 +from django.utils.translation import ugettext as _
  6 +
  7 +
  8 +def colab_send_email(subject, message, to):
  9 + from_email = settings.COLAB_FROM_ADDRESS
  10 + return mail.send_mail(subject, message, from_email, [to])
  11 +
  12 +
  13 +def send_verification_email(to, user, validation_key):
  14 + subject = _('Please verify your email ') + u'{}'.format(to)
  15 + msg_tmpl = loader.get_template('superarchives/emails/email_verification.txt')
  16 + message = msg_tmpl.render(Context({'to': to, 'user': user,
  17 + 'key': validation_key,
  18 + 'SITE_URL': settings.SITE_URL}))
  19 + return colab_send_email(subject, message, to)
... ...