Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
I have installed the latest 6.x-1.x-dev version -- datestamp = "1247486600", but I can't see the email messages under "Recent log entries" (/admin/reports/dblog)
I do see some email log entries, because I set Devel module to log mails in stead of sending them out. But none from author contact, if I disable and "go live", with actual mails being sent out.
Do you know what's going on, perhaps I need to tweak some settings in Drupal to activate email logging?
I couldn't wait, so I found some code in the devel.module, at 1764, which logs email messages in stead of sending them. I tweaked it to log email messages sent via Author Contact -- to start loggin':
This is already in the dev that I see on cvs checkout - I have the code as follows:
//make watchdog entry
watchdog('mail', 'Author Contact: %name-to was sent an e-mail from %name-from using the form on %page', array('%name-to' => $pageAuthor . " <$to>", '%name-from' => $from, '%page' => $params['referrer']));
Placed before the drupal_set_message
I'll see if I can figure out why it's not in the dev download.
[edit] I found I had committed it to HEAD but not 6.x dev - this should now appear in the next 6.x dev snapshot. [/edit]
By the way - I had decided not to log the actual messages as I think is a privacy concern. As far as I know the normal contact form does not log the message itself.
The latest dev version online is now the correct one, from 2009-Oct-30.
There is a flood_register_event in the code, but no flood_is_allowed (which checks if the message limit is reached) so I inserted it two places in the authorcontact.module:
1. In the create block function, where I made two versions. They both alert the user that the message limit is reached, at the top of the form, but 1.2 also prevents the form fields from being shown.
I think I prefer 1.2, since it also makes the flood check in the authorcontact_form_validate function redundant, what do you think?
1.1 Alert user if the message limit is met:
//create block /// NOTE: ORIGINALLY LINE 91
$block['subject'] = t('Contact Author');
//alert user if the message limit is met
if (!flood_is_allowed('authorcontact', variable_get('contact_hourly_threshold', 3))) {
$block['content'] = t('<div class="messages status"><em>') . t('You cannot send more than %number messages per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3))) . t('</em></div>');
}
$block['content'] .= t('<div class="authorcontact-desc">') . variable_get('authorcontact_desc', '') . t('</div>');
$block['content'] .= drupal_get_form('authorcontact_form');
return $block;
}
break; /// NOTE: ORIGINALLY LINE 97
1.2 Alert user if the message limit is met AND hide the form:
//create block /// NOTE: ORIGINALLY LINE 91
//alert user if the message limit is met AND hide form
if (!flood_is_allowed('authorcontact', variable_get('contact_hourly_threshold', 3))) {
$block['content'] = t('<div class="messages status"><em>') . t('You cannot send more than %number messages per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3))) . t('</em></div>');
return $block;
}
else {
$block['subject'] = t('Contact Author');
$block['content'] = t('<div class="authorcontact-desc">') . variable_get('authorcontact_desc', '') . t('</div>');
$block['content'] .= drupal_get_form('authorcontact_form');
return $block;
}
}
break; /// NOTE: ORIGINALLY LINE 97
2. In the form validation function, which displays a warning at the top of the page. If version 1.2 is used, there is no need for it, since the form isn't being shown anyway.
/**
* Validate the form
*/
function authorcontact_form_validate($form_id, $form_values) {
//check for spamming
if (!flood_is_allowed('authorcontact', variable_get('contact_hourly_threshold', 3))) {
form_set_error('contact_hourly_threshold', t('You cannot send more than %number messages per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3))));
}
//check the email address is valid
if(isset($form_values['values']['senderemail'])) {
if (!valid_email_address($form_values['values']['senderemail'])) {
form_set_error('mail', t('The e-mail address you specified is not valid.'));
}
}
}
Hi Ressa, I've added this in as you've suggested in 1.2 above - although I'm still showing the title and description text for the block as I feel this is needed to give the contact note some context.
Thanks for your attention to this, it's greatly appreciated.
Comments
Comment #1
ressaI second that, being able monitor the use of the contact form and spot potential abuse of the system is important.
Comment #2
JmsCrk commentedYou're right, it's a good idea. This feature is now in the dev version.
Comment #3
JmsCrk commentedComment #5
ressaHi James,
I have installed the latest 6.x-1.x-dev version -- datestamp = "1247486600", but I can't see the email messages under "Recent log entries" (/admin/reports/dblog)
I do see some email log entries, because I set Devel module to log mails in stead of sending them out. But none from author contact, if I disable and "go live", with actual mails being sent out.
Do you know what's going on, perhaps I need to tweak some settings in Drupal to activate email logging?
Thanks for making a great module!
Comment #6
ressaI couldn't wait, so I found some code in the devel.module, at 1764, which logs email messages in stead of sending them. I tweaked it to log email messages sent via Author Contact -- to start loggin':
Insert this code...
...after line 109 in authorcontact.module:
After that you should be able to see the messages sent via Author Contact under "Recent log entries" - /admin/reports/dblog
I am not sure what the process is... Maybe testing it and then including it in the latest dev release if it works?
Comment #7
JmsCrk commentedHi Ressa
This is already in the dev that I see on cvs checkout - I have the code as follows:
Placed before the drupal_set_message
I'll see if I can figure out why it's not in the dev download.
Comment #8
JmsCrk commented[edit] I found I had committed it to HEAD but not 6.x dev - this should now appear in the next 6.x dev snapshot. [/edit]
By the way - I had decided not to log the actual messages as I think is a privacy concern. As far as I know the normal contact form does not log the message itself.
Comment #9
JmsCrk commentedComment #10
ressaBeautiful! I think the snapshot just got in, but the latest 6.x dev (6.x-1.x-dev, 2009-Oct-30) is still the old version from 13th of July 2009.
Or do I have to wait a bit more for the latest version?
Comment #11
JmsCrk commentedHi Ressa, I've just downloaded the 6.x-1.x-dev version marked 30 Oct and at the top of the file it says:
// $Id: authorcontact.module,v 1.6.4.5 2009/10/30 03:21:43 justjamesaus Exp $And it has the latest changes in it. Can you confirm that's how it is for you?
Comment #12
ressaHi James,
The latest dev version online is now the correct one, from 2009-Oct-30.
There is a flood_register_event in the code, but no flood_is_allowed (which checks if the message limit is reached) so I inserted it two places in the authorcontact.module:
1. In the create block function, where I made two versions. They both alert the user that the message limit is reached, at the top of the form, but 1.2 also prevents the form fields from being shown.
I think I prefer 1.2, since it also makes the flood check in the authorcontact_form_validate function redundant, what do you think?
1.1 Alert user if the message limit is met:
1.2 Alert user if the message limit is met AND hide the form:
2. In the form validation function, which displays a warning at the top of the page. If version 1.2 is used, there is no need for it, since the form isn't being shown anyway.
Comment #13
ressaOops, I changed the title, I am changing it back 8o)
Comment #14
JmsCrk commentedHi Ressa, I've added this in as you've suggested in 1.2 above - although I'm still showing the title and description text for the block as I feel this is needed to give the contact note some context.
Thanks for your attention to this, it's greatly appreciated.