Changeset b8ef4ab in OpenWorkouts-current for ow/mail.py


Ignore:
Timestamp:
Feb 19, 2019, 6:58:39 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
42d775c
Parents:
07f5190
Message:

(#61) Better templates for "verify your account" emails:

  • Send a multipart text/html email (instead text only)
  • Added some styling to the html version of the email, based on our current login page styles.

Important: as the html version contains html code generated using
request.resource_url() and request.static_url(), when running in
development mode under http://localhost, the links to images
and css files in the rendered email point to localhost, so they
won't work outside the machine running openworkouts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/mail.py

    r07f5190 rb8ef4ab  
    3939def send_verification_email(request, user):
    4040    subject = _('Welcome to OpenWorkouts')
    41     template = 'ow:templates/mail_verify_account.pt'
     41    txt_template = 'ow:templates/mail_verify_account_txt.pt'
     42    html_template = 'ow:templates/mail_verify_account_html.pt'
    4243    verify_link = request.resource_url(user, 'verify', user.verification_token)
    4344    context = {'user': user, 'verify_link': verify_link}
    4445    mailer = get_mailer(request)
    45     body = render(template, context, request)
    46     message = Message(subject=subject, recipients=[user.email], body=body)
     46    txt_body = render(txt_template, context, request)
     47    html_body = render(html_template, context, request)
     48    message = Message(
     49        subject=subject,
     50        recipients=[user.email],
     51        body=txt_body,
     52        html=html_body
     53    )
    4754    message = idna_encode_recipients(message)
    4855    mailer.send_to_queue(message)
Note: See TracChangeset for help on using the changeset viewer.