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

Escaped HTML in e-mail body #59

Open
sttwister opened this issue Mar 19, 2012 · 4 comments
Open

Escaped HTML in e-mail body #59

sttwister opened this issue Mar 19, 2012 · 4 comments

Comments

@sttwister
Copy link

Hi,

Whenever I send an e-mail, the first and last bits of the e-mail (i.e. viewing the e-mail on the website or unsubscribing) is not rendered as HTML. The newsletter content is shown as properly rendered HTML. This is how an e-mail would look like:

<div id="links"> <a name="links"></a> <p> If you cannot see this email, <a href="http://localhost:8000/newsletter/html-test/1-7fb23b4e5ab0e9eeff80/">click here</a>. </p> </div>

Newsletter HTML content goes here!

<div id="unsubscription"> <a name="unsubscription"></a> <p> For unsubscribing to this mailing list, <a href="http://localhost:8000/newsletter/mailing/unsubscribe/html-test/1-7fb23b4e5ab0e9eeff80/">click here</a>. </p> </div> <img src="http://localhost:8000/newsletter/tracking/newsletter/html-test/1-7fb23b4e5ab0e9eeff80.jpg" width="1" height="1" />

I tried reading all the docs, double-checked that all the dependencies are properly installed, nothing worked so far.

Thanks!

@Tyrdall
Copy link

Tyrdall commented Apr 2, 2012

Got the same problem. This is what I get:

--===============1405334309==
Content-Type: multipart/alternative; boundary="===============0565937462=="
MIME-Version: 1.0

--===============0565937462==
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<div id=3D"links"> <a name=3D"links"></a> <p> If you cannot see this email,=
<a href=3D"http://example.com/newsletters/fsdfsdfsd/1-5ea22c72d208b99e0984/">clickhere</a>. </p> </div> <div id=3D"unsubscription"> <a name=3D"unsubscription"></a>
<p> For unsubscribing to this mailing list, <a href=3D"http://example.com/newsletters/mailing/unsubscribe/fsdfsdfsd/1-    5ea22c72d208b99e0984/">click here</a>.
</p> </div> <img src=3D"http://example.com/newsletters/tracking/newsletter/fsdfsdfsd/1-5ea22c72d208b99e0984.jpg" width=3D"1" height=3D"1" /> Hey you!


--===============0565937462==
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html>
 <head>
 </head>
 <body>
  &lt;div id=3D"links"&gt;
  &lt;a name=3D"links"&gt;&lt;/a&gt;
  &lt;p&gt;
    If you cannot see this email,
    &lt;a href=3D"http://example.com/newsletters/fsdfsdfsd/1-5ea22c72d208b9=
9e0984/"&gt;click here&lt;/a&gt;.
  &lt;/p&gt;
&lt;/div&gt;
  &lt;div id=3D"unsubscription"&gt;
  &lt;a name=3D"unsubscription"&gt;&lt;/a&gt;
  &lt;p&gt;
    For unsubscribing to this mailing list,
    &lt;a href=3D"http://example.com/newsletters/mailing/unsubscribe/fsdfsd=
fsd/1-5ea22c72d208b99e0984/"&gt;click here&lt;/a&gt;.
  &lt;/p&gt;
&lt;/div&gt;
  &lt;img src=3D"http://example.com/newsletters/tracking/newsletter/fsdfsdf=
sd/1-5ea22c72d208b99e0984.jpg" width=3D"1" height=3D"1" /&gt;
 </body>
 <body>
  Hey you!
 </body>
</html>
--===============0565937462==--
--===============1405334309==--

@SimonSarazin
Copy link

Hi, i've the same problem (it was ok one month ago). Did you find any solution ? Thanks

@sttwister
Copy link
Author

The problem seems to be in the body_insertion function: https://github.com/Fantomas42/emencia-django-newsletter/blob/master/emencia/django/newsletter/utils/newsletter.py#L9

I hacked it by removing BeautifulSoup from that function and using a simple search and replace before/after <body> or </body> tags. Not the most elegant solution, but it worked for me.

Later on however, I have decided to make the switch to MailChimp completely and I don't regret it one bit.

@marconius
Copy link
Contributor

Got the same problem when upgrading to Django 1.4. Kevipostal's fix worked. Did not test it with older Django versions though.

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

No branches or pull requests

4 participants