On Nov 2, 4:50 am, Tom Evans <tevans...@googlemail.com> wrote: > On Tue, Nov 2, 2010 at 9:07 AM, andy <flowar...@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', > 'f...@address.com', [ 'recipie...@address.com',]) > html_version = ... > msg.attach_alternative(html_version, 'text/html') > msg.send() > > There are lots of 'gotchas' when sending HTML email. Don't expect > externally referenced resources to be available, don't expect styles > to work correctly in all UAs, don't expect any JS to work. > > Cheers > > Tom
Thanks for the reply, Django password_reset view used send_mail() which seem to send only text. apparently you have to use EmailMultiAlternatives as you pointed out to send html content guess I will have to create my own view and use this instead if I want to send html. Then again it is probably a good idea to send password reset information in plant text. Since it pretty any email client would be able to read plain text. Thanks again Kimani -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.