diff --git a/core_email_API.php b/core_email_API.php index 42381b7a31..0f336b9eb8 100644 --- a/core_email_API.php +++ b/core_email_API.php @@ -489,7 +489,7 @@ function email_send( $p_recipient, $p_subject, $p_message, $p_header="" ) { } $mail->Subject = $t_subject; - $mail->Body = "\n".$t_message; + $mail->Body = make_lf_crlf( "\n".$t_message ); if( !$mail->Send() ) { PRINT "PROBLEMS SENDING MAIL TO: $t_recipient
"; @@ -513,6 +513,11 @@ function email_send( $p_recipient, $p_subject, $p_message, $p_header="" ) { # $t_headers .= "Content-Type: text/html; charset=iso-8859-1\n"; $t_headers .= $p_header; + + $t_recipient = make_lf_crlf( $t_recipient ); + $t_subject = make_lf_crlf( $t_subject ); + $t_message = make_lf_crlf( $t_message ); + $t_headers = make_lf_crlf( $t_headers ); $result = mail( $t_recipient, $t_subject, $t_message, $t_headers ); if ( TRUE != $result ) { PRINT "PROBLEMS SENDING MAIL TO: $t_recipient

"; @@ -553,4 +558,16 @@ function email_build_subject( $p_bug_id ) { return "[".$p_project_name." ".$p_bug_id."]: ".$p_subject; } # -------------------- + # clean up LF to CRLF + function make_lf_crlf( $p_string ) { + global $g_strip_bare_lf; + + if ( ON == $g_strip_bare_lf ) { + $p_string = str_replace( "\n", "\r\n", $p_string ); + return str_replace( "\r\r\n", "\r\n", $p_string ); + } else { + return $p_string; + } + } + # -------------------- ?> \ No newline at end of file diff --git a/doc/ChangeLog b/doc/ChangeLog index 4e0f73a632..3b5f2de93f 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -68,6 +68,7 @@ Mantis * Added jump to bug form. * Added core_proj_user_API.php. * Added make_lf_crlf() to remove bare line feeds. + * Added g_strip_bare_lf to toggle use of make_lf_crlf(). * Added priority reporting on the report form for developers. * Removed access_min and access threshold concepts from the user and project management. * Removed extra "echo" in news archive page. diff --git a/doc/configuration.html b/doc/configuration.html index 746db35371..810c3095f0 100644 --- a/doc/configuration.html +++ b/doc/configuration.html @@ -343,6 +343,17 @@

Content

+ + + $g_strip_bare_lf + + + Some Mail transfer agents (MTAs) don't like bare linefeeds... or they take good input and create bare linefeeds. + If problems occur when sending mail through your server try turning this OFF +

+ More details here: http://pobox.com/~djb/docs/smtplf.html + + $g_use_phpMailer