I am getting error messages when sending e-mail from Drupal (i.e. for new user registrations, password resets), appearing in the system events log as:

"Error mailing password to demo at me@mydomain.com"

I contacted my host, and they said:

Due to the tightening of our antispam measures, you will need to make sure your form is sending from a valid address on the domain.

In your mail send program, you will have a line something like this. Please change the following line:

mail($recipient,$subject,$message,$from);

to

mail($recipient,$subject,$message,$from," -f user@domain.com");

where user@domain.com is a valid email address

I insisted that Drupal was well-written and I didn't need to edit any core code, but they said this is the issue. Yet, I can't find this line anywhere in the actual Drupal code. I have set the FROM address in settings to an actual address on the domain.

Can anyone help?

Thanks!

--Dave

Comments

DaveNotik’s picture

Forgot to add: Drupal 4.6, Linux.

micha_1977’s picture

...my host demands it too...

this "line" is inside the user.module in

/your_drupal_root/modules/user.module

search for

function user_mail

and go to the end of this function you will see

    return mail(
      $mail,
      mime_header_encode($subject),
      str_replace("\r", '', $message),
      "MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8Bit\n" . $header    );

change it to

    return mail(
      $mail,
      mime_header_encode($subject),
      str_replace("\r", '', $message),
      "MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8; format=flowed\nContent-transfer-encoding: 8Bit\n" . $header,
      " -f user@domain.com"
    );

do not forget the single , after $header

this should work
-micha
work in progress with Drupal 4.6: langmi.de

DaveNotik’s picture

Thank you -- that worked.

Shouldn't this be moved out of user.module and made a setting in Drupal? e.g. if your host requires e-mail to originate from a valid e-mail address on the domain, enter the e-mail address here...

--Dave

nathandigriz’s picture

Using variable_get('site_mail', ini_get('sendmail_from')) in the above code should handle that.

sachinchvn’s picture

hello dear friends,,,

Hi there,

iam using drupal 7, and for some reason my drupal setup is not able to send out user registration links to users, or no messages are being sent like welcome or change password msg, no mesaging is working at all so i was hoping you could help me thanks, please advice, this is such a serious problem, i have tried uninstalling and reinstalling drupal end number of times no use, what could be the problem?

thanks

sachin