You are here

function mailhandler_user_load_alias in Mailhandler 6

Same name and namespace in other branches
  1. 7 mailhandler.module \mailhandler_user_load_alias()

Look up a user based on their mailalias addresses

Helper function for mailhandler_authenticate_tokenauth()

Parameters

$fromaddress: String from address

$node: Object node object

$mailbox: Array of mailhandler mailbox configuration

Return value

Object user object or FALSE

2 calls to mailhandler_user_load_alias()
mailhandler_authenticate_default in ./mailhandler.module
Authenticate message based on sender's email address If the sender's email address matches an email address of a valid user, then assign that user's uid and name to the node object.
mailhandler_authenticate_tokenauth in ./mailhandler.module
Authenticate message based on token from tokenauth module If the user's token is found somewhere in the "to" field, assign that user's uid and name to the node object. A rough search for the token somewhere in the…

File

./mailhandler.module, line 1279
Mailhandler module code.

Code

function mailhandler_user_load_alias($fromaddress, $node, $mailbox) {
  $result = db_query("SELECT mail FROM {users} WHERE data LIKE '%%%s%%'", $fromaddress);
  while ($alias = db_result($result)) {
    if ($from_user = mailhandler_user_load($alias, $node->pass, $mailbox)) {
      return $from_user;
      break;
    }
  }
  return FALSE;
}