Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML emails #132

Open
alexcwatt opened this issue Aug 8, 2017 · 4 comments
Open

HTML emails #132

alexcwatt opened this issue Aug 8, 2017 · 4 comments

Comments

@alexcwatt
Copy link
Contributor

I am implementing HTML emails for a project and noticed that although the email body templates end in .html, they are actually used as text templates. I think the ideal would be to have some default templates but ending in .txt, and letting the user override those as well as providing .html versions. Then if a .html version exists, it will be passed to Django's send_mail function.

Any thoughts on the best way to implement this, since changing from .html to .txt would break existing overrides?

@bennylope
Copy link
Owner

I can think of a couple ways of doing this.

One is having both text and HTML body templates. Another is allowing users to override how the email itself is generated. I'm a bit more partial to this - either it allows people to bring their own HTML email builder and/or basic HTML email handling is added via some new backend classes that ship with the app.

For what it's worth, I'm not against making a breaking change like changing the template from .html to .txt. It could be made in such a way that it isn't immediately breaking or just be documented as part of an upgrade.

@alexcwatt
Copy link
Contributor Author

We could even do both: Let the user provide a .html or .txt version, but also write a new method that returns just the EmailMessage instance. They could then override that if needed.

@bennylope
Copy link
Owner

write a new method that returns just the EmailMessage instance

This sounds like a good strategy to start.

@avianion
Copy link

Is this fixed? How to we go about sending a custom HTML email?

  email_message = self.email_message(
            user, self.invitation_subject, self.invitation_body, sender, **kwargs
        )

Where "invitation_body" here is a custom HTML email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants