the module isn't using the From address which is set in the admin; which is a pretty big deal as most SMTP servers won't authenticate with any from address.

the attach patch has the module use the From variable which is already on the admin form.

#17 smtp-authentication-support-742962.patch2.03
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
smtp-from.patch812 bytesliquidcms
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch smtp-from.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]


liquidcms, the patch will overwrite sender email. This way one will not be able to reply to the Contact module's messages.

Hi and liquidcms - couldn't this be easily solved by modifying the patch to include a 'replyto' and set the original from address to the 'replyto' address?. I am not a coder, so can't figure it out myself?

And/Or, could you not put the original senders email address in the body somehow "this email is from [sender email] sent via [site name] with links?

Hi jpjanze,

I'm not familiar with email headers, if in some way it could be possible to set "reply-to" address, that would solve the problem I think.

As for your second point, I think this will require changes in Contact module, and this change might not be appropriate for other users of that module (those who not use SMTP Authentication Support)

Some explanation on headers:

From this explanation I can conclude that we need to change 'Sender' header. Right now the Sender header is set equivalent to From header. If we set Sender to a parameter from the admin, and leave From as it is now I think we will solve the problem.

I tested, this approach works for me.

In my tests using this module, the emails only contain the header "Sender:" and no "From:" header.
The module seems to be using the "Sender:" field associated w/ the site and not the field defined by the module.

Closing #1147786: "E-mail from address" is not used as a duplicate of this one.

Version:7.x-1.x-dev» 7.x-1.0-beta2

I have a similar situation.

Module is configured to authorize when sending mails (for example, user name is, and some password).

If in the submission form (Webform 7.x-3.18) you specify sender's address as, then sending a content of the form is without error.

But if you specify (in the submission form settings) sender's address, which will be different from, then there is an SMTP server error: 5.7.1 Sender address rejected: not owned by auth user.

P.S.: sorry for my English

Version:7.x-1.0-beta2» 7.x-1.x-dev

Version:7.x-1.x-dev» 7.x-1.0-beta2


Version:7.x-1.0-beta2» 7.x-1.x-dev

Status:Needs review» Closed (works as designed)

A code really similar with the one provided in the patch was already committed a long time ago (lines 73 ~ 100), marking this as work as designed.

Status:Closed (works as designed)» Needs review

Hi wundo,

My suggestion above was different from the original patch. I suggest to change the Sender header so that no need "to hack to fix reply-to issue". This will also fix "You are not allowed to send mail from domain" error, which still exists.

Here is my patch for the current code in repository. Can you please review it?

diff --git a/smtp.module b/smtp.module
index 4f61170..ea46cb6 100644
--- a/smtp.module
+++ b/smtp.module
@@ -342,7 +342,7 @@ function smtp_drupal_mail_wrapper($message) {
   $mail->From     = $from;
   $mail->FromName = $from_name;
-  $mail->Sender   = $from;
+  $mail->Sender   = variable_get('smtp_from', '');
   // Create the list of 'To:' recipients.

To make clear bug description.

This module works only when From address is same as SMTP account. This is good when you just send notifications. But Contacts module uses different From address. And most SMTP servers deny to send contact form messages (to prevent spam, as you pretend to be other domain).

So, the module should handle different From address properly. Right now it doesn't.

Status:Needs review» Needs work, could you provide a patch file?
Also, when you do it, could you please remove the code that your change will make deprecated?



The patch is attached. This fixes "You are not allowed to send mail from domain". I do not touch section with reply-to, I must be was wrong about it.

new2.03 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

Status:Needs work» Needs review

Version:7.x-1.x-dev» 7.x-1.0

My version: 7.x-1.0
Both patches posted above do not solve the issue. From field in emails is always the username of the smtp authentication (it happens in my case that it's a valid email address).

Version:7.x-1.0» 7.x-1.x-dev

@berte, please don't change the module version of the issue to the module version you are using.

patches are created to be applied to dev versions, and not to stable versions.

please consider downloading the dev version and testing the patches again.

also, you don't need to "subscribe" manually anymore, on the top right corner you can click "Follow".

thank you.

Issue summary:View changes

The patch at #17 works. Anonymous and authenticated users are able to send mail by submitting the core contact form. The from address they enter is retained as the sending address.


The from address they enter is retained as the sending address.

fwiw this behaviour will change in D8: #111702: Set fixed "from:" and add "Reply-to:" to improve deliverability of Drupal mail

this will help drupal send email to services that implement DKIM/SPF/DMARC anti-spam tests, like yahoo: