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

Use premailer for HTML #178

Closed
gabn88 opened this issue Jan 13, 2016 · 14 comments
Closed

Use premailer for HTML #178

gabn88 opened this issue Jan 13, 2016 · 14 comments
Labels

Comments

@gabn88
Copy link
Contributor

gabn88 commented Jan 13, 2016

I'm using the app now and it works great!

However, I would like to use a Premailer, because my mail shows up in the wrong format on some devices. Is this possible and has anyone done this before?

@dokterbob
Copy link
Collaborator

Obviously, this is possible. However, I have not seen it implemented yet.

Would be a very worthwhile feature though, although perhaps this is more something to do manually once when creating the templates?

@gabn88
Copy link
Contributor Author

gabn88 commented Jan 13, 2016

Well, that is of course also a good option! But the problem in my case was that the preview was incorrect. I had a * {font-family: "Helvetica Neue" arial etc} that got overwritten in many mail programs. I have manually fixed it now, but I think running a premailer before the preview would also solve this?

@dokterbob
Copy link
Collaborator

Thought about it for a bit. I guess this could be implemented but I am a bit afraid of adding another (hard) dependency.

I've noticed in the code that there are actually two places where templates are rendered. It would be good to abstract this out to having a single place (i.e. the templates model) and then providing a configuration option to enable premailer.

If you provide a patch, make sure to provide a basic test and documentation as well. Thanks!

@dokterbob dokterbob changed the title How to use a premailer with Django Newsletter? Use premailer for HTML Jan 31, 2016
@isaac-jordan
Copy link
Contributor

@dokterbob Is it possible to do this currently? I'm using Python premailer in conjunction with another django-app (comments system), is there any way to integrate it in the current version of django-newsletter?

@dokterbob
Copy link
Collaborator

dokterbob commented Feb 8, 2016 via email

@isaac-jordan
Copy link
Contributor

@dokterbob Thanks for the suggestion! I've got it working well using django-premailer. Also lets me have all the emails for my site inherit from the same base, which is nice.

@dokterbob
Copy link
Collaborator

Thanks for the feedback!

It would be great if you could find some time to write something about this in the documentation, I’m sure many users would appreciate!

@isaac-jordan
Copy link
Contributor

@dokterbob I'll PR an example in the docs sometime in the next couple days :)

@dokterbob
Copy link
Collaborator

Great, thanks!

@isaac-jordan
Copy link
Contributor

@dokterbob You mentioned earlier up that you were thinking about having/not having this as part of django-newsletter, and being enabled by a config setting. Did you have any more thoughts on what you would regard as the best solution?

Options seem to be to have it as part of django-newsletter, or just indicate that people use an app such as django-premailer.

@dokterbob
Copy link
Collaborator

As it is perfectly doable to have this functionality without integrating it explicitly, I'd prefer just documenting this as an optional approach, as @Sheepzez has done in #191.

@gabn88
Copy link
Contributor Author

gabn88 commented Feb 22, 2016

Wow, thanks! Never imagined it would be so easy to integrate it!! Thank you!

dsanders11 pushed a commit to dsanders11/django-newsletter that referenced this issue May 2, 2016
@woodz-
Copy link

woodz- commented Jan 31, 2019

Since peterbe's python based premailer depends on lxml, it expects pure and highly ISO/IEC/W3C compliant source html. That's why the sample in the doc is with pure html.

This confused me in the first step. Because I am trying to reuse the message.html template. Inheritance would be better, but newsletter templates lack the presence of { % block %} elements.
I have no explicit application in my django project. I just try to reuse the newsletter application as lightweight as possible by including it into my project. Overall it does its job well. But when it comes to styling I feel things get complicated.

Reusing the message.html template and putting premailer tags there isn't going to work, because of the reason I mentioned above.

Then what is a generic way to style the newsletter templates, especially the ones for emailing?
@Sheepzez: how does your structure look? You mentioned you have a base template from where you inherit. And you are using the premailer. So, how does your config look like?

@dokterbob
Copy link
Collaborator

@woodz- Maybe create a new ticket specifically addressing the issues you're experiencing, and then referring the one here. That way, others are better able to find it.

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

No branches or pull requests

4 participants