if (!$this->getMetadata('identity_check') &&
(count($recip['list']) === 1) &&
isset($opts['identity'])) {
- $identity_search = $opts['identity']->getMatchingIdentity($recip['list']);
+ $identity_search = $opts['identity']->getMatchingIdentity($recip['list'], false);
if (!is_null($identity_search) &&
($opts['identity']->getDefault() != $identity_search)) {
$this->_metadata['identity_check'] = true;
/**
* Returns the identity's id that matches the passed addresses.
*
- * @param mixed $addresses Either an array or a single string or a
- * comma-separated list of email addresses.
- * @param boolean $search_ties Search for a matching identity in tied
- * addresses too?
+ * @param mixed $addresses Either an array or a single string or a
+ * comma-separated list of email addresses.
+ * @param boolean $search_own Search for a matching identity in own
+ * addresses also?
*
* @return integer The id of the first identity that from or alias
* addresses match (one of) the passed addresses or
* null if none matches.
*/
- public function getMatchingIdentity($addresses, $search_ties = true)
+ public function getMatchingIdentity($addresses, $search_own = true)
{
if (!isset($this->_cached['tie_addresses'])) {
$this->_cached['tie_addresses'] = $this->getAllTieAddresses();
if (empty($address['mailbox'])) {
continue;
}
+
$find_address = $address['mailbox'];
if (!empty($address['host'])) {
$find_address .= '@' . $address['host'];
/* Search 'tieto' addresses first. */
/* Check for this address explicitly. */
- if ($search_ties &&
- isset($this->_cached['tie_addresses'][$find_address])) {
+ if (isset($this->_cached['tie_addresses'][$find_address])) {
return $this->_cached['tie_addresses'][$find_address];
}
/* If we didn't find the address, check for the domain. */
- if (!empty($address['host'])) {
- $host = '@' . $address['host'];
- if ($search_ties &&
- isset($this->_cached['tie_addresses'][$host]) &&
- ($host != '@')) {
- return $this->_cached['tie_addresses'][$host];
- }
+ if (!empty($address['host']) &&
+ isset($this->_cached['tie_addresses']['@' . $host])) {
+ return $this->_cached['tie_addresses']['@' . $host];
}
/* Next, search all from addresses. */
- if (isset($this->_cached['own_addresses'][$find_address])) {
+ if ($search_own &&
+ isset($this->_cached['own_addresses'][$find_address])) {
return $this->_cached['own_addresses'][$find_address];
}
}