=== modified file 'src/identityprovider/emailutils.py' --- src/identityprovider/emailutils.py 2018-08-22 22:33:08 +0000 +++ src/identityprovider/emailutils.py 2019-08-29 15:29:29 +0000 @@ -64,22 +64,28 @@ return formataddr((name, address)) -def send_templated_email(subject, template, context, email, from_address=None): +def send_templated_email(subject, template, context, email, from_address=None, title=None): msg = render_to_string(template, context=context) if from_address is None: from_address = format_address(settings.NOREPLY_FROM_ADDRESS) + if title is None: + title = 'Ubuntu One' + + html = render_to_string('email/html/email.html', {'title':title, 'content':msg}) + if not isinstance(email, (tuple, list)): email = [email] return send_mail( - subject, - msg, - from_address, - [format_address(e) for e in email] + subject = subject, + message = msg, + from_email = from_address, + recipient_list = [format_address(e) for e in email], + html_message = html ) -def send_fancy_email(subject, template, context, email, from_address=None): +def send_fancy_email(subject, template, context, email, from_address=None, title=None): if from_address is None: from_address = format_address( settings.NOREPLY_FROM_ADDRESS, @@ -87,7 +93,7 @@ ) subject = u"%s: %s" % (settings.NOREPLY_FROM_NAME, subject) return send_templated_email(subject, template, context, email, - from_address) + from_address, title) def _should_add_invalidation_link(email): @@ -178,7 +184,7 @@ template = 'email/desktop-newuser.txt' send_fancy_email( - _('Finish your registration'), template, context, email) + _('Finish your registration'), template, context, email, None, 'Finish your registration') return token, invalidate_email_token @@ -219,7 +225,7 @@ context, token, invalidate_email_token = _context_for_email_request( root_url, account, email, AuthTokenType.PASSWORDRECOVERY, redirection_url, requester_email=email) - send_fancy_email(subject, template, context, email) + send_fancy_email(subject, template, context, email, None, 'Password reset') return token, invalidate_email_token @@ -236,7 +242,7 @@ send_fancy_email( _("Password change notification"), 'email/password-changed.txt', - context=context, email=email.email) + context=context, email=email.email, from_address=None, title='Password changed') def send_printed_codes_renewal_email(root_url, account, devices): @@ -257,7 +263,7 @@ send_fancy_email( _("Printed list of backup codes is nearly used up"), 'email/printed-codes-nearly-exhausted-warning.txt', - context=context, email=email) + context=context, email=email, from_address=None, title='Backup codes') def send_validation_email_request(root_url, account, email, @@ -281,7 +287,7 @@ requester_email=preferredemail_email, oid_token=oid_token) send_fancy_email( _("Validate your email address"), 'email/validate-email.txt', - context, email) + context, email, None, 'Validate your email address') return token, invalidate_email_token @@ -300,7 +306,8 @@ send_fancy_email( _("The email address {email} was removed from your account").format( email=invalidated_email), - 'email/email-invalidated.txt', context=context, email=email) + 'email/email-invalidated.txt', context=context, email=email, + from_address=None, title='Email address removed') def send_notification_to_invalidated_email_address(root_url, account, @@ -315,14 +322,16 @@ ), 'email/invalidate_email_confirmation.txt', context=context, - email=invalidated_email + email=invalidated_email, + from_address=None, + title='Email address invalidated' ) def send_preferred_changed_notification(email, new_preferred): send_fancy_email( _('E-mail change notification'), 'email/preferred-changed.txt', - {'new_preferred': new_preferred}, email) + {'new_preferred': new_preferred}, email, None, 'Preferred email changed') def send_invitation_after_password_reset(root_url, email): @@ -330,7 +339,7 @@ url = urljoin(root_url, reverse('new_account')) send_fancy_email( _("Password reset request"), 'email/invitation.txt', - {'email': email, 'signup': url}, email, + {'email': email, 'signup': url}, email, None, 'Password reset request' ) @@ -363,7 +372,8 @@ else: subject = _('Account to be deleted - action required') send_fancy_email( - subject, 'email/account-action-required.txt', context, email, + subject, 'email/account-action-required.txt', context, email, None, + 'Action required' ) return token, invalidate_email_token === added directory 'src/webui/templates/email/html' === added file 'src/webui/templates/email/html/email.html' --- src/webui/templates/email/html/email.html 1970-01-01 00:00:00 +0000 +++ src/webui/templates/email/html/email.html 2019-08-29 15:29:29 +0000 @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + {{ title }} + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + + +
+ + + + +
+ {{ content|linebreaks|urlize }} +
+
+
+
+ +
+ + + + + +
+ + + +
+
+
+                       +                       +                 +
+ + +