Using Drupal core's Contact module, the messages I receive through it always have my website's e-mail address as the "from" field. While it really should be the e-mail address of the person who sent me the message.

This seems similar to http://drupal.org/node/200415, but I don't think it's the same thing.

Comments

clivesj’s picture

I have the same thing.

Although this report deals with Dr4.x the problem i'm having is the same.

It worked good before until some 4 weeks ago. The problems began when I:

  • Upgraded to D5.3
  • Install module masscontact
  • Patched module smtp (to work correctly with bcc)

I will try to de-patch module.smtp and see what happens.

Also have a look at:
http://www.drupal.org/node/135320
http://www.drupal.org/node/133789

oadaeh’s picture

Are you both sure you're using the latest version of this module? I've tested this every way I can think of, and I always get the e-mail address that is in the field labeled "Your e-mail address". Would you please re-download and re-install the module (and make sure there isn't another copy lying around somewhere) and see if it is still doing it.

Maybe more details of your configuration might help.

I do see that the from name is always the site name, unless specified on the settings page to be something different. Based on the way the e-mail is sent in the module, I don't think I can change that.

Edit: also, including a list of steps you went through to produce this behavior would be very helpful to me.

wim leers’s picture

Yes I was/am using the latest version of this module. I only installed the module once and can assure you no other version is lying around. When I find the time, I'll collect more details.

clivesj’s picture

namens = 'on behalf of' in Dutch.

With these options set:

  • SMTP email options-> name: smpt_name | email: smtp_mail
  • Siteconfig options-> name: site_name | email: site_email

Outlook list view:
From: site_name
When mail is viewed (clicked open):
From: site_email namens smtp_name [email_from_contact_form]
When mail is forwarded the body will show:
From site_email [mailto:site_email] namens smtp_name

excerpt from mail header:

Return-Path:
From: "smtp_name"
Errors-To: site_mail
Sender: site_mail
Envelope-To: email_to_contact_form

With these options set:

  • SMTP email options-> name: blank | email: blank
  • Siteconfig options -> name: site_name | email: site_email
  • Outlook list view:
    From: site_name
    When mail is viewed (clicked open):
    From: site_email namens site_name [email_from_contact_form]
    When mail is forwarded the body will show:
    From site_email [mailto:site_email] namens site_name

    Return-Path:
    From: "site_name"
    Errors-To: site_mail
    Sender: site_mail
    Envelope-To: email_to_contact_form

    So the from_email on the contact_form will only show-up when you actually open to view the email. It will be shown after the websites name or the name entered in de SMTP config.
    When you fwd this mail -e.g. to a person to attend the mail, the from_email will disappear, whilst a few months ago it would show-up in the body of the email being forwarded.

    If you need more info or if there are diff things i have to check, let me know.

clivesj’s picture

I have traced to behaviour-change to the change made in common.inc in D5.2.

Since I went from 5.1 to 5.3 directly this change remained unnoticed to me until then.
So this patch doesn't work well for me.
I switched back to 5.1 common.inc and now the mail behaviour is like I want.

Maybe Wim could confirm these finding. If confirmed, we can close this issue and file a new one under core.

wim leers’s picture

Assigned: Unassigned » wim leers

When I find the time, I'll do some Drupal debugging to find the exact cause.

Sidenote:

Actually the behavior is correct: the e-mail is being sent from my site, so my site's e-mail address should be used. However, the reply-to should contain the e-mail address of the person who contacted me.

But Drupal 5 (nor 6) allows us to set the "reply-to" separately from the "from". Hence we should continue to use the "from".

mr.j’s picture

Same problem. Subscribing

open-keywords’s picture

You may give a try to this one http://drupal.org/node/224601

wim leers’s picture

Status: Active » Closed (duplicate)

The patch you posted there is working! Marking this issue as a duplicate of yours.

wim leers’s picture

Status: Closed (duplicate) » Active

Ugh, I'm not sure how blind I was, but it's *not* working.

wim leers’s picture

Title: Wrong "from" field value » Wrong reply-to header
Status: Active » Needs review
StatusFileSize
new764 bytes

The modifications to get the reply-to field filled in properly turned out to be super easy… You were assigning a variable to $mail->AddReplyTo, while that actually was a function! Additionally, I added a check to see if the Reply-To header matches the Return-Path header, and if so, don't add a Reply-To address.

Patch attached.

oadaeh’s picture

@Wim Leers, are you saying that the patch in comment #11 fixes the problem you originally reported?

@clivesj, does the patch fix your probelm as well?

wim leers’s picture

@oadaeh: yes, it fixes the original problem.

However, the original problem states that the sender of the contact message should be in the "From" header. That's incorrect, as many e-mail services don't allow the "From" header to be different from the actual sender, including Gmail. So the correct solution is to set the reply-to address. You were already doing this, but you had done so incorrectly (stupid minor bug).

open-keywords’s picture

@Wim Leers,
thanks for finding sorting this out.

But I don't understand what you're trying to do by comparing to the value of Return-Path.
It would be interesting to test the value of From, but Return-Path is :

--------------
quote from http://www.ietf.org/rfc/rfc2821.txt :

The primary purpose of the Return-path is to designate the address to
which messages indicating non-delivery or other mail system failures
are to be sent. For this to be unambiguous, exactly one return path
SHOULD be present when the message is delivered. Systems using RFC
822 syntax with non-SMTP transports SHOULD designate an unambiguous
address, associated with the transport envelope, to which error
reports (e.g., non-delivery messages) should be sent.
--------------

Replies are set to the From, unless there is a Reply-To header with a different value.

What do you think ?

wim leers’s picture

Status: Active » Needs review

Hm, perhaps something else than Return-Path should be used. But it's definitely useful to compare.

This is a dump of the arguments drupal_mail_wrapper() receives:

Array
(
    [0] => contact-page-mail
    [1] => work@example.com
    [2] => [Drupal work] test subject
    [3] => Wim Leers sent a message using the contact form at
http://wimleers.com/contact.

test message
    [4] => the_person_that_is_using_the_contact_form@gmail.com
    [5] => Array
        (
            [MIME-Version] => 1.0
            [Content-Type] => text/plain; charset=UTF-8; format=flowed
            [Content-Transfer-Encoding] => 8Bit
            [X-Mailer] => Drupal
            [Errors-To] => website@example.com
            [Return-Path] => website@example.com
            [Sender] => website@example.com
            [Reply-To] => the_person_that_is_using_the_contact_form@gmail.com
            [From] => the_person_that_is_using_the_contact_form@gmail.com
        )

)

As you can see, the From value equals the Reply-To value. Which makes sense.

However, the From value that you can see here, is *not* respected by the SMTP module. It will override it with the e-mail address of the SMTP account that is used to send e-mail. And that's perfectly fine.

So that's why I'm comparing with Return-Path. Maybe comparing with Sender is better?

open-keywords’s picture

Wim,

In my opinion, I would leave PHP Mailer classes decide on the business logic, and then on such precedence or comparisons, since it has (should have) the experience and knowledge of proper SMTP usages and policies.

However, where the STMP module should be perfect, is in its integration of PHP Mailer. The integration shouldn't loose any header value, shouldn't feed the From value as the recipient, etc...

This requires a little review of the PHP Mailer classes to understand their assumptions, and proper algorithmic of the SMTP module.
You pointed out a bug in the integration (API usage), Great ! Don't fix it with a superfluous and inappropriate business logic !

wim leers’s picture

First of all: it's just a minor thing: it's just to avoid a superfluous header. This could even be considered information overhead, thus an annoyance for the recipient.

Next, I completely understand and respect your point of view. Note however, that this is *above* the level of PHP Mailer: it's in smtp.module's code.

clivesj’s picture

Wim's patch in #11 works OK.
Will it be incorporated in the module?

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Since we won't see another tester, marking this RTBC to get attention from the developer. Thanks for the review, clivesj.

oadaeh’s picture

Status: Reviewed & tested by the community » Fixed
wim leers’s picture

Yay! Thanks :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

Chad_Dupuis’s picture

Status: Closed (fixed) » Active

I'm not sure this is fixed, although the patch certainly helps. It appears to be a problem with the interpretation of various mail clients - most particularly gmail.

I have been using the smtp module and google apps for my email on a number of domains for quite some time with no issues - however, I use an imap client instead of reading it online. When you read the mails via the web client (i.e. gmail) you get the wrong reply to address when you click reply.

This is what you see in the headers:

from	address-on-the-form@mail.com <smtpaddress@yoursite.com>
reply-to	address-on-the-form@mail.com
to	smtpaddress@yoursite.com

Gmail picks up the section in within <> on the from field and replys to that even though the from and the reply-to addresses are both correct. If you read the same message in a reasonable mail client (i.e. thunderbird, evolution, etc.) it does the right thing.

So I'm not sure whether the smtp module should leave out the section in <> on the from field or if this is just a problem with gmail that should be reported??

Chad_Dupuis’s picture

Upon further investigation this appears to be a known "bug" with gmail. Basically if you are sending outbound with the same address you are reading with, gmail ignores the from and reply-to fields and just uses the sent as address. If you go outbound with a different account say "outbound@yourdomain.com" and read it with "webmaster@yourdomain.com" it respects the fields.

Not sure the smtp module can do anything about this.... so I'll leave it open in case you have any ideas, but feel free to close it if there is nothing that can be done. Just wanted to save some folks some time if possible....

moklett’s picture

@Chad_Dupuis: Do you have any references to this "known bug" behavior of Gmail? I haven't been able to find any other mentions of it (and if there are other potential workarounds)

Chad_Dupuis’s picture

There are numerous discussions of it within google groups and other places (google "gmail ignores reply-to header"), I also verified it myself. I do, however, use google apps instead of regular gmail, but I think I tried that as well. The best workaround would probably be to use a separate account for outbound mail from the site. That way it will always respect the fields.

CMangrum’s picture

EDIT: I'm leaving the original comment below since it was still an issue as of this morning. However, during my troubleshooting I disabled and re-enabled the SMTP module from within the module's settings area and it now appears to be working correctly again. Perhaps the module needed to be kicked in the head following my drupal update (6.7-6.8). The headers are correct as follows:

from No Reply
reply-to test@test.com
to contact@site.info
date Thu, Dec 25, 2008 at 2:41 PM
subject [Contact site] contact
mailing list contact.site.info

---
I believe this is also an issue in D6.8. I have SMTP Authentication Support v. 6.x-1.0-beta3 installed and sometime in the last month the behavior changed. I use Gmail but the user in the SMTP server settings is different from the recipient address. Now I'm stuck trying to figure out whether the issue is with Gmail, the SMTP module, D6.8 (since I just upgraded from a previous release), or some combination of those. Since it appears to stem from the reply-to address being wrong (see below), I would guess that it has something to do with the D6.8 contact module's interaction with the SMTP module.

Prior to the middle of November, email sent from the sitewide contact form would have a headers like this (the reply-to is correctly filled in with the contact form value):
from No Reply
reply-to user@hotmail.com
to contact@site.info
date Sat, Nov 15, 2008 at 2:37 PM
subject [Contact Site]

Now I see the following (notice that the reply-to is now the same as the from field):
from No Reply
reply-to do-not-reply@site.info
to contact@site.info
date Thu, Dec 25, 2008 at 11:02 AM
subject [Contact Site]
mailing list contact.site.info

My SMTP settings have the account info filled for using Gmail, a blank "From address", and a populated "From name".

wwwoliondorcom’s picture

Hi,

My websites are sending emails to users (comment notifications, etc...).

Some users might have changed their email or closed the email address used to register.

How to know when my websites are sending emails to addresses that do not exist anymore and how to know about errors when sending emails through my websites ? (delivery failure messages?)

Knowing which mails do not work anymore i could update my users list and avoid sending emails that return errors and bounce back again in the future.

Thanks for help.

wwwoliondorcom’s picture

Any help ?

Thank you.

clivesj’s picture

oliondor,
I think your question is "off-topic".
But anyway: The delivery failure messages should automatically go to your reply-to address.
In my setup this is no-reply@domain.com.
Be aware that you will get a lot of failure messages since also delayed deliveries will be sent to you.
In my case no-reply is a VALID address (it excists) however it is routed to // (Which is the trash-bin)
So I don't see the failure mails.

Things may also depent on your mailserver (serverside) setup.
Good luck

wwwoliondorcom’s picture

Thank you, but i have never set any reply to address ?! Are you speaking about your email address at the Site information ?

And I never got any bouncing email since 2 years that i am using Drupal, so i guess there is something wrong ?

Thanks again.

clivesj’s picture

Yes it will use the email entered on the Site Information Page.
BUT, if you have SMTP module installed the value entered on that page (email from) will superseed the value entered on site info.
In my set-up the SMTP-page-email is left blank, so it uses the other one.

You can have a look a look in your cache table, the value van the variable "site_mail" is the one being used.
Regards

ferrangil’s picture

StatusFileSize
new103.52 KB
new114.94 KB
new59.19 KB

Sorry to revamp this issue, but it looks something is happening with the reply-to header.
It was working fine, using the contact form, and one could just reply and the email was sent to the user entered email (in the form), not to the original email.

Please see the screenshots attached. some_time_ago.png was a sample old email I get and I could reply just by clicking reply. Note the Reply-To header is on place (and working).
The screenshot today_emails.png is what I get now. Clicking Reply (both in thunderbird and also on gmail, etc..) results in an email sent to the original "system" email, not to the user who used the contact form.

Its a big problem as I'm getting replys between users to the website email!! They doesn't know they need to manual specify the email or the reply is not going to be received by the user who firstly contacted them...

Any help will be appreciated! Thanks

wim leers’s picture

Same problem here … something broke this!

ferrangil’s picture

It might be related with Google Apps? Are you using them, Wim? Maybe they remove the reply-to header, to fight spam or some other reason...

If anyone have more info, please explain!

Chad_Dupuis’s picture

I believe I've fixed this in the contact module both 5.x and 6.x -- (this has nothing to do with the SMTP module as far as I can tell). See - http://drupal.org/node/366238

And just to save you some time, you'll need a similar fix for the forward module if you happen to use that - http://drupal.org/node/366926

Let me know if that helps you.

ferrangil’s picture

Thanks; also using the Forward module in fact, so thanks again.

franz’s picture

Status: Needs review » Active
StatusFileSize
new826 bytes

First of all, it seems quite clear that the gmail SMTP overwrites the from address only to match the account used to login, if you're using SMTP module to send the mail trough smtp.gmail.com.

This patch fix of that on the 6.x-dev using the code from #36's link. It also tries to be smart and not overwrite mail that other modules might have send with a proper reply-to address. I tested this with the Contact form, and it's working nicely. =)

Someone could work on a similar patch for the 5.x-dev, if it still applies.

Since it sets the header

franz’s picture

StatusFileSize
new826 bytes

First of all, it seems quite clear that the gmail SMTP overwrites the from address only to match the account used to login, if you're using SMTP module to send the mail trough smtp.gmail.com.

This patch fix of that on the 6.x-dev using the code from #36's link. It also tries to be smart and not overwrite mail that other modules might have send with a proper reply-to address. I tested this with the Contact form, and it's working nicely. =)

Someone could work on a similar patch for the 5.x-dev, if it still applies.

Since it sets the header

franz’s picture

StatusFileSize
new826 bytes

First of all, it seems quite clear that the gmail SMTP overwrites the from address only to match the account used to login, if you're using SMTP module to send the mail trough smtp.gmail.com.

This patch fix of that on the 6.x-dev using the code from #36's link. It also tries to be smart and not overwrite mail that other modules might have send with a proper reply-to address. I tested this with the Contact form, and it's working nicely. =)

Someone could work on a similar patch for the 5.x-dev, if it still applies.

Since it sets the header

franz’s picture

StatusFileSize
new826 bytes

First of all, it seems quite clear that the gmail SMTP overwrites the from address only to match the account used to login, if you're using SMTP module to send the mail trough smtp.gmail.com.

This patch fix of that on the 6.x-dev using the code from #36's link. It also tries to be smart and not overwrite mail that other modules might have send with a proper reply-to address. I tested this with the Contact form, and it's working nicely. =)

Someone could work on a similar patch for the 5.x-dev, if it still applies.

Since it sets the header

franz’s picture

StatusFileSize
new826 bytes

First of all, it seems quite clear that the gmail SMTP overwrites the from address only to match the account used to login, if you're using SMTP module to send the mail trough smtp.gmail.com.

This patch fix of that on the 6.x-dev using the code from #36's link. It also tries to be smart and not overwrite mail that other modules might have send with a proper reply-to address. I tested this with the Contact form, and it's working nicely. =)

Someone could work on a similar patch for the 5.x-dev, if it still applies.

franz’s picture

ping

franz’s picture

First of all, it seems quite clear that the gmail SMTP overwrites the from address only to match the account used to login, if you're using SMTP module to send the mail trough smtp.gmail.com.

I fixed 6.x-dev using the code from #36's link. It also tries to be smart and not overwrite mail that other modules might have send with a proper reply-to address. I tested this with the Contact form, and it's working nicely. =)

http://drupalcode.org/viewvc/drupal/contributions/modules/smtp/smtp.modu...

Someone could work on a similar patch for the 5.x-dev, if it still applies.

wundo’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)