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

Comments

Projects
None yet
4 participants
@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

This comment has been minimized.

Copy link
Owner

dokterbob commented Jan 13, 2016

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

dokterbob commented Jan 31, 2016

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 added the feature label Jan 31, 2016

@dokterbob dokterbob changed the title How to use a premailer with Django Newsletter? Use premailer for HTML Jan 31, 2016

@dokterbob dokterbob added the ready label Jan 31, 2016

@Sheepzez

This comment has been minimized.

Copy link
Contributor

Sheepzez commented Feb 8, 2016

@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

This comment has been minimized.

Copy link
Owner

dokterbob commented Feb 8, 2016

@Sheepzez

This comment has been minimized.

Copy link
Contributor

Sheepzez commented Feb 14, 2016

@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

This comment has been minimized.

Copy link
Owner

dokterbob commented Feb 15, 2016

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!

@Sheepzez

This comment has been minimized.

Copy link
Contributor

Sheepzez commented Feb 15, 2016

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

@dokterbob

This comment has been minimized.

Copy link
Owner

dokterbob commented Feb 16, 2016

Great, thanks!

@Sheepzez

This comment has been minimized.

Copy link
Contributor

Sheepzez commented Feb 17, 2016

@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

This comment has been minimized.

Copy link
Owner

dokterbob commented Feb 17, 2016

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.

@dokterbob dokterbob closed this Feb 17, 2016

@dokterbob dokterbob removed the ready label Feb 17, 2016

@gabn88

This comment has been minimized.

Copy link
Contributor Author

gabn88 commented Feb 22, 2016

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

dsanders11 added a commit to dsanders11/django-newsletter that referenced this issue May 2, 2016

@woodz-

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

dokterbob commented Feb 1, 2019

@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