Drupal eMail: Fixing from and reply-to information (Core Hack)

In Drupal 5 and 6, when a user submits the contact form, and email gets generated and sent to the site maintainer (or whatever address is set in the conact form). This email is sent from the server so clicking reply will send an email back to the server, not the email address the submitter set int he form.

The core hack to contact.pages.inc below fixes this so that reply-to address is the sender.

Note: in some providers like gmail, if the from address is the same as the to address, then the reply-to value is ignored. To work around this behaviour, use two different address. i.e. from address is website@example.com and to address is admin@example.com


http://drupal.org/node/366238

Contact Form Fix For Drupal 6 (From and Reply-To Formation)
Chad_Dupuis - May 17, 2009 - 04:03
In drupal 6 you can use hook_mail_alter to change the information within a particular module (or globally if you build your own module) to correct this issue. My code for d6 to correct mails from the contact module is as follows (add the following to the end of contact.pages.inc)

+
+function contact_mail_alter(&$message) {
+ $properfrom = variable_get('site_mail','');
+ $properreplyto = $message['from'];
+ $message['headers']['From'] = $properfrom;
+ $message['headers']['Reply-To'] = $properreplyto;
+}