Many use Google Apps mail and Gmail for their Drupal websites contact form. Google has some restrictions though that may be a inconvenience for the site owner when responding to email correspondence. What happens is the sender's email address will always be the Google account email address rather than the one in the form or in the settings for sending the form. One way to compensate for this is to add the sender's email address to the body of the email.
Doing this requires a patch or hand coding in Drupal 6. Drupal 7 should have the fix already. Just add the placeholder for the sender's address to the body of the email.
/** * Implementation of hook_mail(). */ function contact_mail($key, &$message, $params) { $language = $message['language']; switch ($key) { case 'page_mail': case 'page_copy': $contact = $params['contact']; $message['subject'] .= t('[!category] !subject', array('!category' => $contact['category'], '!subject' => $params['subject']), $language->language); //$message['body'][] = t("!name sent a message using the contact form at !form.", array('!name' => $params['name'], '!form' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language))), $language->language); $message['body'][] = t("!name (!from) sent a message using the contact form at !form.", array('!name' => $params['name'], '!from' => $params['mail'], '!form' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language))), $language->language); $message['body'][] = $params['message']; break; case 'page_autoreply': $contact = $params['contact']; $message['subject'] .= t('[!category] !subject', array('!category' => $contact['category'], '!subject' => $params['subject']), $language->language); $message['body'][] = $contact['reply']; break; case 'user_mail': case 'user_copy': $user = $params['user']; $account = $params['account']; $message['subject'] .= '['. variable_get('site_name', 'Drupal') .'] '. $params['subject']; $message['body'][] = "$account->name,"; $message['body'][] = t("!name (!name-url) has sent you a message via your contact form (!form-url) at !site.", array('!name' => $user->name, '!name-url' => url("user/$user->uid", array('absolute' => TRUE, 'language' => $language)), '!form-url' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language)), '!site' => variable_get('site_name', 'Drupal')), $language->language); $message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", array('absolute' => TRUE, 'language' => $language))), $language->language); $message['body'][] = t('Message:', NULL, $language->language); $message['body'][] = $params['message']; break; } }
Unix Patch:
? show_from_in_contact_email-d6.patch Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.103 diff -u -p -r1.103 contact.module --- modules/contact/contact.module 16 Jan 2008 12:46:52 -0000 1.103 +++ modules/contact/contact.module 8 Mar 2008 06:23:13 -0000 @@ -166,7 +166,7 @@ function contact_mail($key, &$message, $ case 'page_copy': $contact = $params['contact']; $message['subject'] .= t('[!category] !subject', array('!category' => $contact['category'], '!subject' => $params['subject']), $language->language); - $message['body'][] = t("!name sent a message using the contact form at !form.", array('!name' => $params['name'], '!form' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language))), $language->language); + $message['body'][] = t("!name (!from) sent a message using the contact form at !form.", array('!name' => $params['name'], '!from' => $params['mail'], '!form' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language))), $language->language); $message['body'][] = $params['message']; break; case 'page_autoreply':
I added the patch here because it's easier to save a directory of patches than it is to remember all your code hacks ;)
