I am getting from part of a mail sent from my drupal 7 website like below

From: (site mail address) On Behalf Of (sender mail address)

Here I want to remove everything except sender email address, how can I do this?

I have found following url but it is expired


Any help???



1 Answer 1


Well you can write a simple module, and in your module insert this function. Here is where i got the idea

function yourmodule_mail_alter(&$message)
    $message['headers']['Sender'] = $message['headers']['From'];

If you want to go with quick sketch comment, in the link to completely get rid of the headers use

function mymodule_mail_alter(&$message) {

There is also a module that can help out with this mail headers

Control and modify any (almost any) mail header. Mail Headers allows you to:

  • have you tried it out anytime?
    – Vamshi
    Commented Sep 26, 2013 at 10:01
  • Yes, and it worked fine.
    – 4life
    Commented Sep 26, 2013 at 10:02
  • In the above three solutions which one do you suggest me to use with respect to my scenario?
    – Vamshi
    Commented Sep 26, 2013 at 10:06
  • They are now just two. I would suggest using the last one.
    – 4life
    Commented Sep 26, 2013 at 10:08
  • With the last solution should I get the sender's email address in the from part? Sorry for asking without trying but my site in live. I will make changes once I get the clear picture.
    – Vamshi
    Commented Sep 26, 2013 at 10:11

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