emencia / emencia-django-newsletter

An app for sending newsletter by email to a contact list.
189 stars 72 forks source link

Escaped HTML in e-mail body #59

Open sttwister opened 12 years ago

sttwister commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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

sttwister commented 12 years ago

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 commented 12 years ago

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