You are here

public function MailhandlerAuthenticateTokenauth::authenticate in Mailhandler 6.2

Same name and namespace in other branches
  1. 7.2 modules/mailhandler_tokenauth/plugins/mailhandler/authenticate/MailhandlerAuthenticateTokenauth.class.php \MailhandlerAuthenticateTokenauth::authenticate()

Authenticates an incoming message.

Parameters

$item: Array containing message headers, body, and mailbox information.

Overrides MailhandlerAuthenticate::authenticate

File

modules/mailhandler_tokenauth/plugins/mailhandler/authenticate/MailhandlerAuthenticateTokenauth.class.php, line 26
MailhandlerAuthenticateTokenauth class.

Class

MailhandlerAuthenticateTokenauth
Authenticate message based on token from tokenauth module.

Code

public function authenticate(&$message, $mailbox) {
  list($fromaddress, $fromname) = _mailhandler_get_fromaddress($message['header'], $mailbox);
  $uid = 0;

  // If user with given email address exists and their token is in the toaddress, allow.
  if (($from_user = user_load(array(
    'mail' => $fromaddress,
  ))) && strpos($header->to[0]->mailbox, tokenauth_get_token($from_user->uid)) !== FALSE) {
    $uid = $from_user->uid;
  }
  return $uid;
}