I'm increasingly finding that hosting providers are tightening up on email policies, including blocking emails coming from sites hosted on their servers where the From: address is not in the same domain as the website. This approach means that Drupal's contact form stops working. A better approach could be to have the contact form send emails with the site's admin address as the From: address, and include the sender's address elsewhere.

Comments

rickfitz’s picture

Issue summary: View changes

As of 7.26 (not checked earlier releases), the sender's name and email address are included in the message body, but it still tries to send using the sender's email address, so is rejected by the SMTP server.

A very simple patch to 'contact.pages.inc' seems to fix this, at least for my usage. In each call to 'drupal_mail' simply delete the last parameter. This causes Drupal to use the site's default email address instead.

I guess the ideal fix would be to add a config option to use either the sender's address or the site's address.

CDU’s picture

This also causes Gmail to reject contact emails because the "From" address is different than the "Sender" address in the email headers.

I know you are not supposed to hack the Drupal core, but I had to, in order to stop Gmail from rejecting these emails, or marking them as spam.

I changed line 152 in the contact.pages.inc file from this:
drupal_mail('contact', 'page_mail', $to, language_default(), $values, $from);

to this:
drupal_mail('contact', 'page_mail', $to, language_default(), $values);

This solved my immediate problem, but it would be nice if this was fixed in future releases of the Drupal core.

I second rickfitz's suggestion that "the ideal fix would be to add a config option to use either the sender's address or the site's address."

erald’s picture

Yahoo is also rejecting mails with email address [name]@yahoo.com
Getting nuts of Yahoo changing to rules all the time..

this patch helps. to avoid the problem.

dcam’s picture

Version: 7.15 » 8.x-dev

Changes will have to be made in 8.x first.

greg.1.anderson’s picture

I have fixed this problem in a Drupal 7 site with hook_mail_alter. See #2219627: Contact Form: sender address uses not the configured sender #3.

larowlan’s picture

Priority: Normal » Minor

As there is an existing work-around involving hook_mail_alter, dropping this to minor

andypost’s picture

Status: Active » Closed (duplicate)