mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-29 10:09:10 +01:00
try to cope with broken emailaddresses in our parseAddressList when using Horde_Mail_Rfc822->parseAddressList (returning empty object when fed with a broken address)
This commit is contained in:
parent
e0fa44f401
commit
1244c6c7de
@ -6306,11 +6306,22 @@ class emailadmin_imapbase
|
|||||||
{
|
{
|
||||||
$rfc822 = new Horde_Mail_Rfc822();
|
$rfc822 = new Horde_Mail_Rfc822();
|
||||||
$ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array());
|
$ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array());
|
||||||
|
//error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count);
|
||||||
|
if ((empty($ret) || $ret->count()==0)&& is_string($addresses) && strlen($addresses)>0)
|
||||||
|
{
|
||||||
|
$matches = array();
|
||||||
|
preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches);
|
||||||
|
//error_log(__METHOD__.__LINE__.array2string($matches));
|
||||||
|
foreach ($matches[0] as &$match) $match = trim($match,', ');
|
||||||
|
$addresses = implode(',',$matches[0]);
|
||||||
|
//error_log(__METHOD__.__LINE__.array2string($addresses));
|
||||||
|
$ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array());
|
||||||
|
//error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count);
|
||||||
|
}
|
||||||
//foreach($ret as $i => $adr) error_log(__METHOD__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal --> ".$adr);
|
//foreach($ret as $i => $adr) error_log(__METHOD__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal --> ".$adr);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a read notification
|
* Send a read notification
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user