Hi.

In the documentation of this module says:

Note however, that Google automatically rewrites the "from" line of any e-mail
you send via their SMTP gateway to your Google Mail address.

It is ok. I understand it. But this is a problem for "Contact" Module. When a user send an email from a contact form, gmail overwrite the sender and if I check my mailbox and click on "reply" I will reply to my @gmail account and not to the real sender of the message.

Maybe this module can set the "Reply-to" header to the original sender of the message. Or maybe it is already implemented and I'm doing something wrong. Or maybe it is simply not possible....

Anyway thanks in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dagmar’s picture

Status: Active » Needs review
FileSize
699 bytes

With this patch I have solved my problem. Now when I click on Reply from my inbox I'm reply to the real sender of the message.

sshvetsov’s picture

I agree with dagmar, it is a problem when contact form is used with Google's SMTP server.

My hosting provider is forcing me to use SMTP for all outgoing emails, and Google rewrites the "From" header, so I cannot reply to emails sent to me via contact form.

I'll tried your patch, dagmar, and it does achieve the desired result - ability to click "Reply" and actually send email to original sender.

smk-ka’s picture

Status: Needs review » Closed (won't fix)

I have to disagree here: the PHPMailer module is a dumb library, it takes whatever it is fed and doesn't make any custom alterations specific to a certain configuration.

Luckily, Drupal provides a way to do the required alterations: what you want is a custom hook_mail_alter() implementation, something along the lines of

function custom_mail_alter(&$message) {
  // See contact_mail_page_submit() for all possible ids.
  if ($message['id'] == 'contact_page_mail') {
    $message['headers']['Reply-To'] = $message['from'];
  }
}

(Untested.) Put that code into custom.module, add an .info file and you have the desired Reply-To header in the e-mail.

However, the module didn't actually make use of the Reply-To headers until now, thus you need a decent development snapshot for this technique to work.

dagmar’s picture

Status: Closed (won't fix) » Active

Sorry Stefan, I have to reopen this issue again.

Let me explain better why this feature should be included into PHPMailer module.

First, this patch doesn't modify phpmailer.class.inc, it modified drupal.phpmailer.inc, so it can be implemented without hack phpmailer library.

Secondly, there are probably 1000 sites using PHPMailer to send emails from their sites. Probably a lot of them doesn't know that they are replying messages to an incorrect email address. I'm using Drupal for two years and internet for about 10, and discovered this after 3 months of use PHPMailer. Too late.

If you prefer to use a phpmailer_mail_alter() to include this feature as a conditional option, please let me know, and I will write the patch. However, if you insist in your position to keep this option out of PHP Mailer, please, at least add a small note into README.txt preventing users about this behavior.

Grettings
Mariano

smk-ka’s picture

Title: Gmail from emails » Cannot reply to emails sent via Gmail
Status: Active » Needs review
FileSize
2.8 KB

Ok, thought about this again and it seems safe to set Reply-To to the From address if, and only if, the message doesn't contain an explicitly set Reply-To header, otherwise we would possibly add a wrong reply-to address. Since drupal_mail() doesn't set this header, PHPMailer may use the From address unless it has been set by another module. Please test the attached patch.

smk-ka’s picture

Status: Needs review » Needs work

E-mails sent with a Reply-To look ugly in e-mail programs. This should really be turned into an advanced option with an explanation when to enable.

kthull’s picture

I installed the latest dev to try to deal with gmail changing the from address and after running update.php and testing the form, I get this error:

Can not call constructor in /[path]/phpmailer/includes/phpmailer.class.inc on line 26

smk-ka’s picture

@kthull
Which version of the PHPMailer library did you download? It is possible that the latest changes regarding exception handling require one of the 5.0.x versions (5.1 hasn't been tested yet, but should work, too).

kthull’s picture

I used 5.0.2. I can no longer recall how many different things I tried, but I know I had to abandon gmail altogether. I'm using PHPMailer with a non-gmail smtp server and working just fine now.

Thanks!

smk-ka’s picture

Status: Needs work » Fixed
FileSize
5.08 KB

Ok, I've added an option to the settings page and updated the Google Mail instructions accordingly. Committed the attached patch to all branches.

Status: Fixed » Closed (fixed)

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