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.

#30 2015-07-08 15-17-53.jpg64.75 KBalphex
#30 2015-07-08 15-17-11.jpg408.86 KBalphex
#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 ]

Comments’s picture’s picture

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

jpjanze’s picture

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?’s picture

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)’s picture

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.

rodmaz’s picture

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.

Simon Georges’s picture

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

cac2s’s picture

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

Simon Georges’s picture

Version:7.x-1.0-beta2» 7.x-1.x-dev
cac2s’s picture

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


Simon Georges’s picture

Version:7.x-1.0-beta2» 7.x-1.x-dev
wundo’s picture

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.’s picture

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.’s picture

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.

wundo’s picture

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?

thanks’s picture


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.’s picture

new2.03 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
Simon Georges’s picture

Status:Needs work» Needs review
berte’s picture

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).

brunorios1’s picture

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.

paulrooney’s picture

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.


mvc’s picture

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 comply with DMARC

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

Anders Kallin’s picture

I too can confirm that the patch in #17 indeed solves this major problem.

Anders Kallin’s picture

FYI: I just saw that this excellent patch is incompatible with the patch in
My vote is on this patch.

marktompsett’s picture

I would love to use this module as a solution to a DMARC policy issue I am encountering with the Contact form on the site that I am responsible for.
To do that I would need the From header in the message to correctly be the "E-mail from address" that I specify in the "E-mail options" of the "SMTP Authentication Support" screen, which currently it is not.


djinn23’s picture

Not to be that guy, but what expectations would there be to roll this into a stable build or is more testing against this patch required. I have just installed this on my site and seeking as how it is confirmed resolved in the dev build I considered adding that to my sites .... but seeing as how the last Stable release was in Feb I figured it may be rolling out soon. Regardless. Anders brings up an interesting consideration and I am logging this in part to subscribe so I can track the progress.

Thanks for all the efforts.

RunePhilosof’s picture

ericwongcm’s picture

I can also confirm the development version fixed the contact form e-mail from field problem for Drupal 7 described here.

Looks like there is no fix for Drupal 6 yet?

dxx’s picture

No problems, it's good.

alphex’s picture

new408.86 KB
new64.75 KB

Just installed smtp-7.x-1.x-dev via drush.

SMTP email through google apps isn't using the FROM address, it uses the authentication user name in who the message is from when it hits my inbox.

See attached screen shots.

The SMTP user name for authentication is who the email is "FROM", despite there being an address and name provided for "E-mail from address"

SMTP Settings

Test Email Results

Zekvyrin’s picture

Guys can you check this patch:
#2309875-9: Error in 'from' using site-wide contact form and multiple recipients

I think that one has the most expected behaviour.

glynster’s picture

Issue still remains with patch @Zekvyrin suggests. Simply put the from name is working int he SMTP settings but not the email, it always defaults to the SMTP username as @alphex screenshots demonstrate.

bserem’s picture

Status:Needs review» Needs work

Patch on #17 doesn't apply against latest git checkout. I did tha changes manually, but it still doesn't solve the fact that Drupal tries to connect to the SMTP server using the site-wide email (admin/config/system/site-information) instead of the email defined in the SMTP settings.

I'll give it a second try in the night.

andrew.chappell’s picture

I am using 7.x-1.2 and having a similar issue. The email address that is set in /admin/config/system/site-information for site wide usage is overriding the setting used at admin/config/system/smtp. It doesn't matter what I put in to the smtp settings it is always overridden by the site wide setting.