4

My site is made of book(book pages) and any authenticated user is able to send the book page as an e-mail to anybody (other user in the site / external user using e-mail) he wishes. The mail system is working fine but when (lets say) User1(user1@example.com) is sending mail to anyone, the sent mail headers are as follows:

site_admin@example.com on behalf of user1@example.com

I want that a user should be able to send the email directly by his e-mail id.

I am using Drupal 7, with Print and SMTP configured to send to book pages.

5

Apparently someone came up with code to put in a custom module that will remedy this issue:

http://drupal.org/node/461324

I've yet to try it though.

UPDATE:

I tried out an altered version and it worked for me. Here's what I had:

email_sender_override.info:

name = E-mail Sender Override
description = Overrides the 'Sender' of an e-mail message with the 'From' address.
core = 7.x
package = Webform

email_sender_override.module:

<?php
/**
  * @file
  *
  * Mail altering function to override the 'Sender' of a mail message with the address
  * in the 'From' field.
  *
  */

/**
  * email_sender_override_mail_alter
  *
  * Alters the sender of the e-mail message to be the same as the 'From' address.
  * Taken from: http://drupal.org/node/461324
  * See also:   http://api.drupal.org/api/drupal/includes!mail.inc/function/drupal_mail/6#comment-3243
  *             http://drupal.org/node/656472
  *
  * @param message
  *    the full e-mail message being sent -- this will be altered
  */
function email_sender_override_mail_alter(&$message)
{
    $message['headers']['Sender'] = $message['headers']['From'];
}
?>
  • thank you for reply! I'll have a look at it and let you know. – AjitS May 15 '12 at 10:04
  • 1
    I've used that patch and it worked for me. It's worth considering quicksketch's comment about spam - the mails look more 'spammy' and depending on where the mails are being sent to, it could be difficult to measure whether they're getting through or not, so you'd never really know if it was an issue or not. – Andy May 15 '12 at 12:10
2

Nothing much you can do about it. I've had issues with this in the past as well. This is a known issue, and here is a related ticket from drupal.org

It looks like the drupal_mail() function that many modules (like rules) use purposefully sets the user email you specify as the 'From' field in the email, but still puts in your site's default email in the email's 'Sender' information. This causes different email clients to display the email differently. So, for example, Outlook displays the email in the format you're seeing, but Gmail will just display the 'From' information as you were hoping it will do.

Another good comment on this issue can be found in this thread.

Hope this helps clarify the issue a bit!

  • I agree with Andy above. The reason why I posted the thread I did from drupal.org is because in it is discussed why the behavior you're getting is actually correct behavior and why changing it may be perceived as inappropriate or spammy!! It's worth reading through. :-) – Boriana Ditcheva May 16 '12 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.