View Issue Details

IDProjectCategoryView StatusLast Update
0021896mantisbtemailpublic2016-11-27 00:45
ReporterLeChuck Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.17 
Target Version1.3.4Fixed in Version1.3.4 
Summary0021896: Fix Outlook preview for email notifications by removing empty line at top
Description

Usually the body of a mail send by Mantis starts with one sentence that explains what triggered the mail, e.g. "A NOTE has been added to this issue."

In its default view, Outlook shows the subject of an email and the first line of that email (see screenshot "MantisEmptyLineInMail1.png"). But for some reason Mantis starts mails always with an empty line before the "trigger explanation", so Outlook shows this empty line instead of what triggered the mail (which would be really nice info).

After some investigation I finally found that the empty line is added in function email_send (in email_api.php):
<pre>
$mail->Body = make_lf_crlf( "\n" . $t_message );
</pre>

Is there any reason why a newline is added to the message as the first character? I checked the GitHub source history because I was curious, but even the earliest version of that file (25.08.2002) already contains this code.

If I change the line to this
<pre>
$mail->Body = make_lf_crlf( $t_message );
</pre>
the empty line is gone and Outlook shows the "message trigger line".

Additional Information

Mantis 1.2.17
PHP 5.6.17
Windows Server 2012 R2

TagsNo tags attached.
Attached Files
MantisEmptyLineInMail1.png (7,300 bytes)   
MantisEmptyLineInMail1.png (7,300 bytes)   
MantisEmptyLineInMail2.png (4,383 bytes)   
MantisEmptyLineInMail2.png (4,383 bytes)   

Activities

dregad

dregad

2016-11-11 07:10

developer   ~0054504

I looked at the history, and indeed can't think of any reason for adding the newline at the beginning of the message body.

The explanation I can think of, is that a newline is required as separator between the message header and the body, but PHPMailer handles that for us automatically... maybe earlier versions of the library didn't ?

Anyway, I think this extra newline can be safely removed.

PR https://github.com/mantisbt/mantisbt/pull/947

Related Changesets

MantisBT: master-1.3.x 5407ec7d

2016-11-11 01:59

dregad


Details Diff
Remove leading newline from email body

This extra blank line prevents email clients such as Outlook from
displaying a preview of MantisBT's notification messages in a list view.

The newline does not serve any known purpose (PHPMailer already adds one
to separate the message header from its body), and testing does not show
any regression when notifications are sent sent without it.

This commit removes the extra '\n'.

Fixes 0021896
Affected Issues
0021896
mod - core/email_api.php Diff File