On Wed, Nov 21, 2012 at 3:27 PM, larry.mart...@gmail.com
<larry.mart...@gmail.com> wrote:
> On Tuesday, November 2, 2010 5:50:49 AM UTC-4, Tom Evans wrote:
>>
>> On Tue, Nov 2, 2010 at 9:07 AM, andy <flow...@gmail.com> wrote:
>> > I recently tried to send the following in a test password email from a
>> > site I am creating:
>> >
>> > <h1>This is a test reset password email.</h1>
>> >
>> > However when I received the email it displayed the "<h1>This is a test
>> > reset password email.</h1>".
>> >
>> > My question is how can I send a styled email using html tags and
>> > possibly even css when using the password_reset_email.html template
>> > that goes with django's view.password_reset?
>> >
>>
>> I don't know about the specifics of your particular issues, but to
>> send HTML emails:
>>
>> Create an instance of django.core.mail.EmailMultiAlternatives, passing
>> in your subject, text version of the email, from address, list of
>> recipients. Render your HTML version of the email, and attach it to
>> the email, and then send it.
>>
>> eg:
>>
>> from django.core.mail import EmailMultiAlternatives
>> msg = EmailMultiAlternatives('Subject', 'This is the text version',
>> 'fr...@address.com', [ 'recip...@address.com',])
>>
>> html_version = ...
>> msg.attach_alternative(html_version, 'text/html')
>> msg.send()
>
>
> I am having the same issue, but it's not clear to me how to implement your
> solution. I have added the files password_reset_email.html,
> activation_email_subject.txt, password_reset_form.html, and
> password_reset_done.html to my ui/templates/registration dir customized them
> as needed. Where would I put your code above? Where would I call it from?
>
> Thanks!
> -larry

When you use the stock d.c.a.password_reset view, one of the arguments
you can provide is a custom Form class to handle the password reset.
You would provide this as an additional argument supplied in the
urlconf.

The form is what actually sends the email, in the save() method, so by
sub-classing the default form, and overriding the save() method, you
can handle how the email is produced. You would need to duplicate most
of the logic from the default form's save() method, unfortunately.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to