Rendering of e-mail template adds unnecessary whitespace

I have the following e-mail template:

%{message}

%{context}

%{respond_instructions}

Which in turn creates the following e-mail

----==_mimepart_59121ceab749e_713fcbab014f1c98278
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<p><div style='margin-left: 15px'><br>[text]</p>

<p>[text]</p>

<p></div></p>

<hr>

<p><a href="[link]">Visit Topic</a> or reply to this email to respond.</p>

<p>You are receiving this because you enabled mailing list mode.</p>

<p>To unsubscribe from these emails, <a href="[LINK]">click here</a>.</p>
----==_mimepart_59121ceab749e_713fcbab014f1c98278--

The <div style='margin-left: 15px'> creates an unnecessary whitespace indentation and seems odd in itself.

CC: @yuyichao

2 Likes

I assume you are objecting to the suppression of avatar in single short email notifications? This was done to satisfy Spam Assassin rules where small emails with images are penalized.

1 Like

No, I disabled the header because a user asked for it and we wanted to make the mailing-list experience more mailinglist like :wink:

My issue is that the first paragraph is indented and that makes it look like it might be a citation (which it is not). Looking at the raw html of the e-mail there is a spurious <div style='margin-left: 15px'>.

2 Likes

Oh I see @neil can you have a look?

Yeah I see the problem.

result.gsub!(/\[email-indent\]/, "<div style='margin-left: 15px'>")
result.gsub!(/\[\/email-indent\]/, "</div>")

That will create some mangled html.

3 Likes

Fixed.

https://github.com/discourse/discourse/commit/5be7a2dad4a3aab55cda43a92a88d39e21011271

Looks like there was old code trying to indent posts, and it probably worked great… for two days in 2013. This commit became obsolete two days later by this commit when a custom html template was used instead of the markdown. Now we allow customized email templates to be used for HTML, which unearthed this archaeological treasure.

7 Likes

archaeological “treasure”

3 Likes