In drupal webform generated e-mail is grabbing the default email from the site information as a Sender header-information.
Over SMTP when a message is submitted, the SMTP envelope (sender, recipients, etc.) is different from the actual data of the message. The Sender
header is used to identify in the message who submitted it. This is usually the same as the From
header, which is who the message is from. However, it can differ in some cases where a mail agent is sending messages on behalf of someone else.
In drupal, webform generated email sender header and from header is not same, so when anyone check webform generated email using SMTP client they see Sender
header instead of From
header. After some investigations I figured out that in the mail headers the recipient is written nicely by webform (like To: foo@customer.com
), the from is also written nicely by webform (like From: from@customer.com
). But the webform is grabbing the default email from the site information ( /admin/settings/site-information) and sender is written by this address (like Sender: bar@customer.com).
what is causing the problem and confusion.
It looks like Drupal core is responsible for these headers, I know that Webform isn’t adding them.So basically, it’s going to be forced on to any e-mails sent by Webform. The spam argument is valid though, since Drupal is sending the e-mail from it’s server, giving e-mails a different Sender could cause e-mails to be marked as spam on the receiving end. If you really want to get rid of these headers, you can implement hook_mail_alter() in a custom module and rewrite the headers.
/**
* Implementation of hook_mail_alter().
*/
function mymodule_mail_alter(&$message) {
if ($message['id'] == 'webform_submission') {
$message['from'] = $from;
$message['headers']['From'] = $from;
$message['headers']['Sender'] = $from;
$message['headers']['Return-Path'] = $from;
}
}
For more information , Please go through the follow links
https://www.drupal.org/node/461324 and https://www.drupal.org/node/1804214