Jump to:
| Project: | Drupal core |
| Version: | 5.6 |
| Component: | contact.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
We have a sitewide contact form (http://greenopolis.com/beta/contact), which requires a user to enter his or her name, email address, etc. When the form is submitted and the email message is generated, the user's email address is not included in the message that gets constructed in the contact_mail_page_submit($form_id, $form_values) function.
There is a record in watchdog.
I'd like to see something like this:
sent a message using the contact form at !form.", array('!name' => $form_values['name'], '!form' => url($_GET['q'], NULL, NULL, TRUE), '!email' => $form_values['mail']));
$message[] = $form_values['message'];
?>
Is this just an oversight, or is there a reason why the email address is not currently being passed in the body of the message?
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| contact.01292008.patch | 1.17 KB | Ignored: Check issue status. | None | None |
Comments
#1
The reason why this is happening on my site is because I am using the SMTP module, which is overwriting the From field.
However, I contend that at the very least, the contact_mail_page_submit() function should set the Reply-to header to $form_values['mail'].
#2
Ok, but why hacking the core? Can you do something like making your own custom module and adding the _validate or _submit hooks at _form_alter for the 'contact-mail-page' form?
#3
The contact modules does put the correct value for the from/reply-to field. The only problem is with the SMTP module overwriting the value.
#4
Thank you for the patch. Sad to have to patch a core module, but I am sure this is a reason for not having the email in the body. I just can't think of a good reason, but hey, this is not the first Drupal quirk I see, so...
#5
i had the same problem and thanks to thread, didn't have to debug to find the root cause.
it's best is to implement hook_mail_alter in your module. I did the following and it works fine.
function mymodule_mail_alter(&$message){$message['body'][]= t("Sent by "). $message['params']['mail'];
}
If you are on a release < 6, you will need to adapt the function signature.
#6
Thanks for the fix. Since there may be other emails sent out, it's good to check the id first, e.g.
function mymodule_mail_alter(&$message){if ($message['id'] == 'contact_page_mail') {
$message['body'][]= t("Sent by "). $message['params']['mail'];
}
}
Kristen