You are here

function mimemail_post in Mime Mail 7

Same name and namespace in other branches
  1. 5 mimemail.module \mimemail_post()
  2. 6 includes/mimemail.incoming.inc \mimemail_post()

Receive messages POSTed from an external source.

This function enables messages to be sent via POST or some other RFC822 source input (e.g. directly from a mail server).

Return value

The POSTed message.

1 string reference to 'mimemail_post'
mimemail_menu in ./mimemail.module
Implements hook_menu().

File

includes/mimemail.incoming.inc, line 17
Functions that handle inbound messages to mimemail.

Code

function mimemail_post() {
  if (!isset($_POST['token']) || empty($_POST['token'])) {
    return drupal_access_denied();
  }
  if (isset($_POST['message']) && !empty($_POST['message'])) {
    $key = variable_get('mimemail_key', drupal_random_key());
    $hash = hash_hmac('sha1', $_POST['message'], $key);
    if ($hash != $_POST['token']) {
      watchdog('access denied', 'Authentication error for POST e-mail', WATCHDOG_WARNING);
      return drupal_access_denied();
    }
    else {
      return mimemail_incoming($_POST['message']);
    }
  }
  return drupal_access_denied();
}