The Access Denied error is returned because the following code executed by code_site_form(). (Notice the call to drupal_access_denied().)
$limit = variable_get('contact_threshold_limit', 5);
$window = variable_get('contact_threshold_window', 3600);
if (!flood_is_allowed('contact', $limit, $window) && !user_access('administer contact forms')) {
drupal_set_message(t("You cannot send more than %limit messages in @interval. Try again later.", array('%limit' => $limit, '@interval' => format_interval($window))), 'error');
drupal_access_denied();
drupal_exit();
}
Users with the "administer contact forms" permission don't get that error, since the limit for the sent messages doesn't apply to them.
Check those Drupal variables have not been set to different values that lower the number of allowed messages. The default is 5 messages in 1 hour.
As side note, render(drupal_get_form('contact_site_form'))
would cause a "call-time pass-by-reference" warning in PHP 5.3, since render() is expecting a variable passed by reference, but drupal_get_form() doesn't return a reference. PHP 5.4 will raise a fatal error for that same code. The code calling render()
should always use a variable.
module_load_include('inc', 'contact', 'contact.pages');
$form = drupal_get_form('contact_site_form');
print render($form);