There is a line in user.module user_mail() that removes \r from the email body:
str_replace("\r", '', $message),
To make the email comply with the standards the str_replace should be removed. Some unix based mail servers will ignore the lack of the \r while others reject the email as invalid.

If you want to fix the occasional wierd line ending from editors on different operating systems, the following are useful. The following fixes text from some editors that forget the \r while maintaining the \r\n from standards compliant email editors.
str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $message));

Comments

sepeck’s picture

Version: 4.6.3 » 4.6.5

I've seen this bug on a Drupal 4.6.5 install with my site. I am wondering if it is part of the the intermittant missing mail issue Drupal.org has sending new passwords.

killes@www.drop.org’s picture

I've sent myself a drupal.org password reminder and captured the traffic using tcpdump. Looking at the dump with ethereal by myself and somebody who knows what it should look like reveals that the mail is ok and that people not getting mail probably have issues with their spamfilters.

I am inclined to mark this "won't fix".

peterx’s picture

The problem was in mail going out. It failed at the first mail server without passing through a spam checker.

I removed the mailer module in preparation for an upgrade to 4.7.0. I will add the mailer module back after 4.7.0 and report the problem again if it exists in 4.7.0.

dries’s picture

I'm trying the suggested fix in drupal.org. Let's see if that stops some of the user registration problems.

killes@www.drop.org’s picture

I am bit confused now. Which mailer module are ou talking about? Did you have n external smtp server set up?

peterx’s picture

I am trying 4.7.0 beta 6 for a new site. Here is the error message for email before I apply the fix.
warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in /home/example.com/web/modules/user.module on line 400. This is the same error message as displayed in 4.6.

chx’s picture

killes, Dries where are we with this bug?

gerhard killesreiter’s picture

I am not 100% sure, but I /think/ it is fixed in HEAD.

chx’s picture

Gerhard, this code snippet is not touched in HEAD.

itsme213’s picture

On win-XP using apache2triad I got the same SMTP error message.

When I replaced the line in user.module:
str_replace("\r", '', $message),

with

str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $message)),

the error message disappeared and the email was sent fine.

(I also tried replacing the line with just $message; it did not fix the problem).

magico’s picture

Version: 4.6.5 » 4.6.9

Still a problem?

magico’s picture

Status: Active » Closed (fixed)
peterx’s picture

Version: 4.6.9 » 5.0-rc1

The problem occurs with Drupal 5 RC1 in includes/common.inc drupal_mail() about line 1947. Replace:
str_replace("\r", '', $body),
with:
str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $body)),

petermoulding.com/web_architect

GravitySpec’s picture

Thanks for posting this peterx.

This issue was still present in our version 5.6 copy which now uses drupal_mail() in the includes/common.inc file. Your fixed worked like a charm and now our e-mails are getting through to the more strict servers.