* Mail: import and display of mails failed, if personal part of addresses contains valid encoded utf-8 characters

- using now Horde_Mime_Headers::parseHeaders() for headers instead of Mail_mimeDecode, which should be completly replaced with Horde_Mime_Part::parseMessage()
- replaced imap_rfc822_parse_adrlist with Horde_Mail_Rfc822::parseAddressList() using static wrapper emailadmin_imapbase::parseAddressList()
r49066: sending mail was failing after r49065
This commit is contained in:
Ralf Becker 2014-10-20 18:10:31 +00:00
parent 570558ff31
commit 9a2cfa0782
3 changed files with 239 additions and 275 deletions

View File

@ -2040,15 +2040,15 @@ class emailadmin_imapbase
if ($_tryIDNConversion===true && stripos($_string,'@')!==false) if ($_tryIDNConversion===true && stripos($_string,'@')!==false)
{ {
$rfcAddr = imap_rfc822_parse_adrlist($_string,''); $rfcAddr = self::parseAddressList($_string);
if (!isset(self::$idna2)) self::$idna2 = new egw_idna; if (!isset(self::$idna2)) self::$idna2 = new egw_idna;
if (isset(self::$idna2)) if (isset(self::$idna2))
{ {
$stringA = array(); $stringA = array();
//$_string = str_replace($rfcAddr[0]->host,self::$idna2->decode($rfcAddr[0]->host),$_string); //$_string = str_replace($rfcAddr[0]->host,self::$idna2->decode($rfcAddr[0]->host),$_string);
foreach ((array)$rfcAddr as $_rfcAddr) foreach ($rfcAddr as $_rfcAddr)
{ {
if ($_rfcAddr->host=='.SYNTAX-ERROR.') if (!$_rfcAddr->valid)
{ {
$stringA = array(); $stringA = array();
break; // skip idna conversion if we encounter an error here break; // skip idna conversion if we encounter an error here
@ -4495,8 +4495,7 @@ class emailadmin_imapbase
foreach($recepientList as $recepientType) { foreach($recepientList as $recepientType) {
if(isset($headers[$recepientType])) { if(isset($headers[$recepientType])) {
if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true); if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true);
$addresses = imap_rfc822_parse_adrlist($headers[$recepientType], ''); foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) {
foreach($addresses as $singleAddress) {
$addressData = array( $addressData = array(
'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', 'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL',
'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL',
@ -5458,16 +5457,16 @@ class emailadmin_imapbase
} }
if ($addressData['RFC822_EMAIL']) if ($addressData['RFC822_EMAIL'])
{ {
$addressObjectA = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($addressData['RFC822_EMAIL']):$addressData['RFC822_EMAIL']),''); $addressObjectA = self::parseAddressList($addressData['RFC822_EMAIL']);
} }
else else
{ {
$emailaddress = ($addressData['PERSONAL_NAME']?$addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>':$addressData['EMAIL']); $emailaddress = ($addressData['PERSONAL_NAME']?$addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>':$addressData['EMAIL']);
$addressObjectA = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($emailaddress):$emailaddress),''); $addressObjectA = self::parseAddressList($emailaddress);
} }
$addressObject = $addressObjectA[0]; $addressObject = $addressObjectA[0];
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressObject)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressObject));
if ($addressObject->host == '.SYNTAX-ERROR.') continue; if (!$addressObject->valid) continue;
//$mb =(string)$addressObject->mailbox; //$mb =(string)$addressObject->mailbox;
//$h = (string)$addressObject->host; //$h = (string)$addressObject->host;
//$p = (string)$addressObject->personal; //$p = (string)$addressObject->personal;
@ -6065,190 +6064,207 @@ class emailadmin_imapbase
*/ */
function parseFileIntoMailObject($mailObject,$tmpFileName,&$Header,&$Body) function parseFileIntoMailObject($mailObject,$tmpFileName,&$Header,&$Body)
{ {
$message = file_get_contents($tmpFileName); $message = file_get_contents($tmpFileName);
try try
{ {
return $this->parseRawMessageIntoMailObject($mailObject,$message,$Header,$Body); return $this->parseRawMessageIntoMailObject($mailObject,$message,$Header,$Body);
} }
catch (egw_exception_assertion_failed $e) catch (egw_exception_assertion_failed $e)
{ // not sure that this is needed to pass on exeptions { // not sure that this is needed to pass on exeptions
throw new egw_exception_assertion_failed($e->getMessage()); throw new egw_exception_assertion_failed($e->getMessage());
} }
} }
/** /**
* parseRawMessageIntoMailObject - parses a message/rfc mail from file to the mailobject and returns the header and body via reference * Parses a message/rfc mail from file to the mailobject and returns the header and body via reference
* throws egw_exception_assertion_failed when the required Pear Class is not found/loadable *
* @param object $mailObject instance of the SMTP Mailer Object * @param PHPMailer $mailObject instance of the SMTP Mailer Object
* @param mixed string/object $message string containing the RawMessage / object Mail_mimeDecoded message (part)) * @param string|Horde_Mime_Part $message string containing the RawMessage / object Mail_mimeDecoded message (part))
* @param string &$Header reference used to return the imported Mailheader * @param string &$Header reference used to return the imported Mailheader
* @param string &$Body reference to return the imported Body * @param string &$Body reference to return the imported Body
* @throws egw_exception_assertion_failed when the required Horde_Mail_Part not found
* @return void Mailheader and body is returned via Reference in $Header $Body * @return void Mailheader and body is returned via Reference in $Header $Body
*/ */
function parseRawMessageIntoMailObject($mailObject,$message,&$Header,&$Body) function parseRawMessageIntoMailObject(PHPMailer $mailObject, $message, &$Header, &$Body)
{ {
/** /**
* pear/Mail_mimeDecode requires package "pear/Mail_Mime" (version >= 1.4.0, excluded versions: 1.4.0) * pear/Mail_mimeDecode requires package "pear/Mail_Mime" (version >= 1.4.0, excluded versions: 1.4.0)
* ./pear upgrade Mail_Mime * ./pear upgrade Mail_Mime
* ./pear install Mail_mimeDecode * ./pear install Mail_mimeDecode
*/ */
//echo '<pre>'.$message.'</pre>'; //echo '<pre>'.$message.'</pre>';
//error_log(__METHOD__.' ('.__LINE__.') '.$message); //error_log(__METHOD__.' ('.__LINE__.') '.$message);
if (class_exists('Mail_mimeDecode',false)==false && (@include_once 'Mail/mimeDecode.php') === false) throw new egw_exception_assertion_failed(lang('Required PEAR class Mail/mimeDecode.php not found.')); if (class_exists('Mail_mimeDecode',false)==false && (@include_once 'Mail/mimeDecode.php') === false) throw new egw_exception_assertion_failed(lang('Required PEAR class Mail/mimeDecode.php not found.'));
if (is_string($message)) if (is_string($message))
{
$mailDecode = new Mail_mimeDecode($message);
$structure = $mailDecode->decode(array('include_bodies'=>true,'decode_bodies'=>true,'decode_headers'=>true));
}
elseif (is_object($message))
{
$structure = $message;
}
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($structure));
//_debug_array($structure);
//exit;
// now create a message to view, save it in Drafts and open it
$mailObject->PluginDir = EGW_SERVER_ROOT."/phpgwapi/inc/";
$mailObject->IsSMTP();
$mailObject->CharSet = self::$displayCharset; // some default, may be altered by BodyImport
if (isset($structure->ctype_parameters['charset'])) $mailObject->CharSet = trim($structure->ctype_parameters['charset']);
$mailObject->Encoding = 'quoted-printable'; // some default, may be altered by BodyImport
$contenttypecalendar = '';
$myReplyTo = '';
// use Horde code to parse header, Mail_mimeDecode fails with utf-8
$headers = Horde_Mime_Headers::parseHeaders(substr($message, 0, strpos($message, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL)));
foreach($headers->toArray(array('charset' => self::$displayCharset)) as $key => $val)
{
$key = strtolower($key);
//error_log(__METHOD__.' ('.__LINE__.') '.$key.'->'.$val);
foreach((array)$val as $i => $v)
{ {
$mailDecode = new Mail_mimeDecode($message); if ($key!='content-type' && $key !='content-transfer-encoding' &&
$structure = $mailDecode->decode(array('include_bodies'=>true,'decode_bodies'=>true,'decode_headers'=>true)); $key != 'message-id' &&
} $key != 'subject' &&
if (is_object($message)) $key != 'from' &&
{ $key != 'to' &&
$structure = $message; $key != 'cc' &&
} $key != 'bcc' &&
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($structure)); $key != 'reply-to' &&
//_debug_array($structure); $key != 'x-priority') // the omitted values to that will be set at the end
//exit;
// now create a message to view, save it in Drafts and open it
$mailObject->PluginDir = EGW_SERVER_ROOT."/phpgwapi/inc/";
$mailObject->IsSMTP();
$mailObject->CharSet = self::$displayCharset; // some default, may be altered by BodyImport
if (isset($structure->ctype_parameters['charset'])) $mailObject->CharSet = trim($structure->ctype_parameters['charset']);
$mailObject->Encoding = 'quoted-printable'; // some default, may be altered by BodyImport
/*
$mailObject->AddAddress($emailAddress, $addressObject->personal);
$mailObject->AddCC($emailAddress, $addressObject->personal);
$mailObject->AddBCC($emailAddress, $addressObject->personal);
$mailObject->AddReplyto($emailAddress, $addressObject->personal);
*/
$result ='';
$contenttypecalendar = '';
$myReplyTo = '';
foreach((array)$structure->headers as $key => $val)
{
//error_log(__METHOD__.' ('.__LINE__.') '.$key.'->'.$val);
foreach((array)$val as $i => $v)
{ {
if ($key!='content-type' && $key !='content-transfer-encoding' && $Header .= $mailObject->HeaderLine($key, trim($v));
$key != 'message-id' &&
$key != 'subject' &&
$key != 'from' &&
$key != 'to' &&
$key != 'cc' &&
$key != 'bcc' &&
$key != 'reply-to' &&
$key != 'x-priority') // the omitted values to that will be set at the end
{
$Header .= $mailObject->HeaderLine($key, trim($v));
}
} }
switch ($key) }
{ switch ($key)
case 'x-priority': {
$mailObject->Priority = $val; case 'x-priority':
break; $mailObject->Priority = $val;
case 'message-id': break;
$mailObject->MessageID = $val; // ToDo: maybe we want to regenerate the message id all the time case 'message-id':
break; $mailObject->MessageID = $val; // ToDo: maybe we want to regenerate the message id all the time
case 'sender': break;
$mailObject->Sender = $val; case 'sender':
break; $mailObject->Sender = $val;
case 'to': break;
case 'cc': case 'to':
case 'bcc': case 'cc':
case 'from': case 'bcc':
case 'reply-to': case 'from':
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($val):$val),''); case 'reply-to':
$i = 0; $address_array = self::parseAddressList($val);
foreach((array)$address_array as $addressObject) $i = 0;
foreach($address_array as $addressObject)
{
$mb = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$pName = $addressObject->personal;
if ($key=='from')
{ {
$mb = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); $mailObject->From = $mb;
$pName = $addressObject->personal; $mailObject->FromName = $pName;
if ($key=='from')
{
$mailObject->From = $mb;
$mailObject->FromName = $pName;
}
${$key}[$i] = array($mb,$pName);
$i++;
} }
if ($key=='reply-to') ${$key}[$i] = array($mb,$pName);
{ $i++;
$myReplyTo = ${$key}; }
//break; // break early as we add that later if ($key=='reply-to')
} {
$Header .= $mailObject->TextLine(trim($mailObject->AddrAppend(ucfirst($key),${$key}))); $myReplyTo = ${$key};
break; //break; // break early as we add that later
case 'content-transfer-encoding': }
$mailObject->Encoding = $val; $Header .= $mailObject->TextLine(trim($mailObject->AddrAppend(ucfirst($key),${$key})));
break; break;
case 'content-type': case 'content-transfer-encoding':
//error_log(__METHOD__.' ('.__LINE__.') '.' '.$key.'->'.$val); $mailObject->Encoding = $val;
if (stripos($val,'calendar')) $contenttypecalendar = $val; break;
break; case 'content-type':
case 'subject': //error_log(__METHOD__.' ('.__LINE__.') '.' '.$key.'->'.$val);
if (stripos($val,'calendar')) $contenttypecalendar = $val;
break;
case 'subject':
/* /*
error_log(__METHOD__.__LINE__.$val); error_log(__METHOD__.__LINE__.$val);
error_log(__METHOD__.__LINE__.$mailObject->SecureHeader($val)); error_log(__METHOD__.__LINE__.$mailObject->SecureHeader($val));
error_log(__METHOD__.__LINE__.translation::convert($mailObject->SecureHeader($val),false,$mailObject->CharSet)); error_log(__METHOD__.__LINE__.translation::convert($mailObject->SecureHeader($val),false,$mailObject->CharSet));
error_log(__METHOD__.__LINE__.$mailObject->EncodeHeader($mailObject->SecureHeader($val))); error_log(__METHOD__.__LINE__.$mailObject->EncodeHeader($mailObject->SecureHeader($val)));
*/ */
$mailObject->Subject = $mailObject->EncodeHeader(translation::convert($mailObject->SecureHeader($val),false,$mailObject->CharSet)); $mailObject->Subject = $mailObject->EncodeHeader(translation::convert($mailObject->SecureHeader($val),false,$mailObject->CharSet));
$Header .= $mailObject->HeaderLine('Subject',$mailObject->Subject); $Header .= $mailObject->HeaderLine('Subject',$mailObject->Subject);
break; break;
default: default:
// stuff like X- ... // stuff like X- ...
//$mailObject->AddCustomHeader('X-Mailer: FeLaMiMail'); //$mailObject->AddCustomHeader('X-Mailer: FeLaMiMail');
if (!strtolower(substr($key,0,2))=='x-') break; if (!strtolower(substr($key,0,2))=='x-') break;
//case 'priority': // priority is a cusom header field //case 'priority': // priority is a cusom header field
// $mailObject->Priority = $val; // $mailObject->Priority = $val;
// break; // break;
case 'disposition-notification-to': case 'disposition-notification-to':
case 'organization': case 'organization':
foreach((array)$val as $i => $v) $mailObject->AddCustomHeader($key.': '. $v); foreach((array)$val as $i => $v) $mailObject->AddCustomHeader($key.': '. $v);
break; break;
}
}
// handle reply-to, wich may be set, set the first one found
if (!empty($myReplyTo))
{
$mailObject->ClearReplyTos();
$mailObject->AddReplyTo($myReplyTo[0][0],$myReplyTo[0][1]);
} }
}
// handle reply-to, wich may be set, set the first one found
if (!empty($myReplyTo))
{
$mailObject->ClearReplyTos();
$mailObject->AddReplyTo($myReplyTo[0][0],$myReplyTo[0][1]);
}
$seemsToBePlainMessage = false; $seemsToBePlainMessage = false;
if (strtolower($structure->ctype_primary)=='text' && $structure->body) if (strtolower($structure->ctype_primary)=='text' && $structure->body)
{
$mailObject->IsHTML(strtolower($structure->ctype_secondary)=='html'?true:false);
if (strtolower($structure->ctype_primary) == 'text' && strtolower($structure->ctype_secondary) == 'plain' &&
is_array($structure->ctype_parameters) && isset($structure->ctype_parameters['format']) &&
trim(strtolower($structure->ctype_parameters['format']))=='flowed'
)
{ {
$mailObject->IsHTML(strtolower($structure->ctype_secondary)=='html'?true:false); if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." detected TEXT/PLAIN Format:flowed -> removing leading blank ('\r\n ') per line");
if (strtolower($structure->ctype_primary) == 'text' && strtolower($structure->ctype_secondary) == 'plain' && $structure->body = str_replace("\r\n ","\r\n", $structure->body);
is_array($structure->ctype_parameters) && isset($structure->ctype_parameters['format']) &&
trim(strtolower($structure->ctype_parameters['format']))=='flowed'
)
{
if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." detected TEXT/PLAIN Format:flowed -> removing leading blank ('\r\n ') per line");
$structure->body = str_replace("\r\n ","\r\n", $structure->body);
}
$mailObject->Body = $structure->body;
$seemsToBePlainMessage = true;
} }
$this->createBodyFromStructure($mailObject, $structure, $parenttype=null); $mailObject->Body = $structure->body;
$mailObject->SetMessageType(); $seemsToBePlainMessage = true;
$mailObject->CreateHeader(); // this sets the boundary stufff }
//echo "Boundary:".$mailObject->FetchBoundary(1).'<br>'; $this->createBodyFromStructure($mailObject, $structure, $parenttype=null);
//$boundary =''; $mailObject->SetMessageType();
//if (isset($structure->ctype_parameters['boundary'])) $boundary = ' boundary="'.$mailObject->FetchBoundary(1).'";'; $mailObject->CreateHeader(); // this sets the boundary stufff
if ($seemsToBePlainMessage && !empty($contenttypecalendar) && strtolower($mailObject->ContentType)=='text/plain') //echo "Boundary:".$mailObject->FetchBoundary(1).'<br>';
{ //$boundary ='';
$Header .= $mailObject->HeaderLine('Content-Transfer-Encoding', $mailObject->Encoding); //if (isset($structure->ctype_parameters['boundary'])) $boundary = ' boundary="'.$mailObject->FetchBoundary(1).'";';
$Header .= $mailObject->HeaderLine('Content-type', $contenttypecalendar); if ($seemsToBePlainMessage && !empty($contenttypecalendar) && strtolower($mailObject->ContentType)=='text/plain')
} {
else $Header .= $mailObject->HeaderLine('Content-Transfer-Encoding', $mailObject->Encoding);
{ $Header .= $mailObject->HeaderLine('Content-type', $contenttypecalendar);
$Header .= $mailObject->GetMailMIME(); }
} else
$Body = $mailObject->getMessageBody(); // this is a method of the egw_mailer/phpmailer class {
//_debug_array($Header); $Header .= $mailObject->GetMailMIME();
//_debug_array($Body); }
//_debug_array($mailObject); $Body = $mailObject->getMessageBody(); // this is a method of the egw_mailer/phpmailer class
//exit; //_debug_array($Header);
//_debug_array($Body);
//_debug_array($mailObject);
//exit;
}
/**
* Parse an address-list
*
* Replaces imap_rfc822_parse_adrlist, which fails for utf-8, if not our replacement in common_functions is used!
*
* @param string $addresses
* @param string $default_domain
* @return Horde_Mail_Rfc822_List iteratable Horde_Mail_Rfc822_Address objects with attributes mailbox, host, personal and valid
*/
public static function parseAddressList($addresses, $default_domain=null)
{
$rfc822 = new Horde_Mail_Rfc822();
$ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array());
//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;
} }
/** /**
@ -6486,7 +6502,7 @@ error_log(__METHOD__.__LINE__.$mailObject->EncodeHeader($mailObject->SecureHeade
} else if ( isset($headers['X-CONFIRM-READING-TO']) ) { } else if ( isset($headers['X-CONFIRM-READING-TO']) ) {
$toAddr = $headers['X-CONFIRM-READING-TO']; $toAddr = $headers['X-CONFIRM-READING-TO'];
} else return false; } else return false;
$singleAddress = imap_rfc822_parse_adrlist($toAddr,''); $singleAddress = self::parseAddressList($toAddr);
if (self::$debug) error_log(__METHOD__.__LINE__.' To Address:'.$singleAddress[0]->mailbox."@".$singleAddress[0]->host.", ".$singleAddress[0]->personal); if (self::$debug) error_log(__METHOD__.__LINE__.' To Address:'.$singleAddress[0]->mailbox."@".$singleAddress[0]->host.", ".$singleAddress[0]->personal);
$send->AddAddress($singleAddress[0]->mailbox."@".$singleAddress[0]->host, $singleAddress[0]->personal); $send->AddAddress($singleAddress[0]->mailbox."@".$singleAddress[0]->host, $singleAddress[0]->personal);
$send->AddCustomHeader('References: '.$headers['MESSAGE-ID']); $send->AddCustomHeader('References: '.$headers['MESSAGE-ID']);

View File

@ -471,9 +471,8 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
$mailObject->MessageID = $message->headers['message-id']; $mailObject->MessageID = $message->headers['message-id'];
/* the client send garbage sometimes (blackberry->domain\username) /* the client send garbage sometimes (blackberry->domain\username)
// from // from
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($message->headers['from']):$message->headers['from']),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($message->headers['from']):$message->headers['from'])) as $addressObject) {
foreach((array)$address_array as $addressObject) { if (!$addressObject->valid) continue;
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
if ($this->debugLevel>0) debugLog("Header Sentmail From: ".array2string($addressObject).' vs. '.array2string($message->headers['from'])); if ($this->debugLevel>0) debugLog("Header Sentmail From: ".array2string($addressObject).' vs. '.array2string($message->headers['from']));
$mailObject->From = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); $mailObject->From = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$mailObject->FromName = $addressObject->personal; $mailObject->FromName = $addressObject->personal;
@ -481,39 +480,34 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
*/ */
// prepare addressee list; moved the adding of addresses to the mailobject down // prepare addressee list; moved the adding of addresses to the mailobject down
// to // to
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($message->headers["to"]):$message->headers["to"]),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($message->headers["to"]):$message->headers["to"])) as $addressObject) {
foreach((array)$address_array as $addressObject) { if (!$addressObject->valid) continue;
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
if ($this->debugLevel>0) debugLog("Header Sentmail To: ".array2string($addressObject) ); if ($this->debugLevel>0) debugLog("Header Sentmail To: ".array2string($addressObject) );
//$mailObject->AddAddress($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal); //$mailObject->AddAddress($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal);
$toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); $toMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
} }
// CC // CC
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($message->headers["cc"]):$message->headers["cc"]),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($message->headers["cc"]):$message->headers["cc"])) as $addressObject) {
foreach((array)$address_array as $addressObject) { if (!$addressObject->valid) continue;
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
if ($this->debugLevel>0) debugLog("Header Sentmail CC: ".array2string($addressObject) ); if ($this->debugLevel>0) debugLog("Header Sentmail CC: ".array2string($addressObject) );
//$mailObject->AddCC($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal); //$mailObject->AddCC($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal);
$ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); $ccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
} }
// BCC // BCC
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($message->headers["bcc"]):$message->headers["bcc"]),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($message->headers["bcc"]):$message->headers["bcc"])) as $addressObject) {
foreach((array)$address_array as $addressObject) { if (!$addressObject->valid) continue;
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
if ($this->debugLevel>0) debugLog("Header Sentmail BCC: ".array2string($addressObject) ); if ($this->debugLevel>0) debugLog("Header Sentmail BCC: ".array2string($addressObject) );
//$mailObject->AddBCC($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal); //$mailObject->AddBCC($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal);
$bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); $bccMailAddr[] = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal);
} }
/* /*
// AddReplyTo // AddReplyTo
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($message->headers['reply-to']):$message->headers['reply-to']),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($message->headers['reply-to']):$message->headers['reply-to'])) as $addressObject) {
foreach((array)$address_array as $addressObject) { if (!$addressObject->valid) continue;
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
if ($this->debugLevel>0) debugLog("Header Sentmail REPLY-TO: ".array2string($addressObject) ); if ($this->debugLevel>0) debugLog("Header Sentmail REPLY-TO: ".array2string($addressObject) );
$mailObject->AddReplyTo($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal); $mailObject->AddReplyTo($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal);
} }
*/ */
$addedfullname = false;
// save some headers when forwarding mails (content type & transfer-encoding) // save some headers when forwarding mails (content type & transfer-encoding)
$headers = ""; $headers = "";
@ -605,8 +599,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
$toCount = 0; $toCount = 0;
//error_log(__METHOD__.__LINE__.array2string($toMailAddr)); //error_log(__METHOD__.__LINE__.array2string($toMailAddr));
foreach((array)$toMailAddr as $address) { foreach((array)$toMailAddr as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
foreach((array)$address_array as $addressObject) {
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); $emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress,(isset($cSMRMethod)?$cSMRMethod:'REQUEST'))) continue; if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress,(isset($cSMRMethod)?$cSMRMethod:'REQUEST'))) continue;
$mailObject->AddAddress($emailAddress, $addressObject->personal); $mailObject->AddAddress($emailAddress, $addressObject->personal);
@ -615,8 +608,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
} }
$ccCount = 0; $ccCount = 0;
foreach((array)$ccMailAddr as $address) { foreach((array)$ccMailAddr as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
foreach((array)$address_array as $addressObject) {
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); $emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
$mailObject->AddCC($emailAddress, $addressObject->personal); $mailObject->AddCC($emailAddress, $addressObject->personal);
@ -625,8 +617,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
} }
$bccCount = 0; $bccCount = 0;
foreach((array)$bccMailAddr as $address) { foreach((array)$bccMailAddr as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
foreach((array)$address_array as $addressObject) {
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); $emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue; if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress)) continue;
$mailObject->AddBCC($emailAddress, $addressObject->personal); $mailObject->AddBCC($emailAddress, $addressObject->personal);
@ -928,8 +919,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
} }
if (count($folderArray) > 0) { if (count($folderArray) > 0) {
foreach((array)$bccMailAddr as $address) { foreach((array)$bccMailAddr as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) {
foreach((array)$address_array as $addressObject) {
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); $emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$mailAddr[] = array($emailAddress, $addressObject->personal); $mailAddr[] = array($emailAddress, $addressObject->personal);
} }
@ -1122,33 +1112,29 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
$mailObject->Subject = $headers['SUBJECT']; $mailObject->Subject = $headers['SUBJECT'];
$mailObject->MessageID = $headers['MESSAGE-ID']; $mailObject->MessageID = $headers['MESSAGE-ID'];
// from // from
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($headers['FROM']):$headers['FROM']),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['FROM']):$headers['FROM'])) as $addressObject) {
foreach((array)$address_array as $addressObject) {
//debugLog(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); //debugLog(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject));
if ($addressObject->host == '.SYNTAX-ERROR.') continue; if (!$addressObject->valid) continue;
$mailObject->From = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); $mailObject->From = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$mailObject->FromName = $addressObject->personal; $mailObject->FromName = $addressObject->personal;
//error_log(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject)); //error_log(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject));
} }
// to // to
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($headers['TO']):$headers['TO']),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['TO']):$headers['TO'])) as $addressObject) {
foreach((array)$address_array as $addressObject) {
//debugLog(__METHOD__.__LINE__.'Address to add (TO):'.array2string($addressObject)); //debugLog(__METHOD__.__LINE__.'Address to add (TO):'.array2string($addressObject));
if ($addressObject->host == '.SYNTAX-ERROR.') continue; if (!$addressObject->valid) continue;
$mailObject->AddAddress($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal); $mailObject->AddAddress($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal);
} }
// CC // CC
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($headers['CC']):$headers['CC']),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['CC']):$headers['CC'])) as $addressObject) {
foreach((array)$address_array as $addressObject) {
//debugLog(__METHOD__.__LINE__.'Address to add (CC):'.array2string($addressObject)); //debugLog(__METHOD__.__LINE__.'Address to add (CC):'.array2string($addressObject));
if ($addressObject->host == '.SYNTAX-ERROR.') continue; if (!$addressObject->valid) continue;
$mailObject->AddCC($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal); $mailObject->AddCC($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal);
} }
// AddReplyTo // AddReplyTo
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($headers['REPLY-TO']):$headers['REPLY-TO']),''); foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($headers['REPLY-TO']):$headers['REPLY-TO'])) as $addressObject) {
foreach((array)$address_array as $addressObject) {
//debugLog(__METHOD__.__LINE__.'Address to add (ReplyTO):'.array2string($addressObject)); //debugLog(__METHOD__.__LINE__.'Address to add (ReplyTO):'.array2string($addressObject));
if ($addressObject->host == '.SYNTAX-ERROR.') continue; if (!$addressObject->valid) continue;
$mailObject->AddReplyTo($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal); $mailObject->AddReplyTo($addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''),$addressObject->personal);
} }
$Header = $Body = ''; // we do not use Header and Body we use the MailObject $Header = $Body = ''; // we do not use Header and Body we use the MailObject

View File

@ -1140,9 +1140,7 @@ class mail_compose
//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
$value = htmlspecialchars_decode($value,ENT_COMPAT); $value = htmlspecialchars_decode($value,ENT_COMPAT);
$value = str_replace("\"\"",'"',$value); $value = str_replace("\"\"",'"',$value);
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($value):$value), ''); foreach(emailadmin_imapbase::parseAddressList($value) as $addressObject) {
//unset($content[strtolower($destination)]);
foreach((array)$address_array as $addressObject) {
if ($addressObject->host == '.SYNTAX-ERROR.') continue; if ($addressObject->host == '.SYNTAX-ERROR.') continue;
$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
//$address = mail_bo::htmlentities($address, $this->displayCharset); //$address = mail_bo::htmlentities($address, $this->displayCharset);
@ -1416,9 +1414,9 @@ class mail_compose
function generateRFC822Address($_addressObject) function generateRFC822Address($_addressObject)
{ {
if(!empty($_addressObject->personal) && !empty($_addressObject->mailbox) && !empty($_addressObject->host)) { if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) {
return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
} elseif(!empty($_addressObject->mailbox) && !empty($_addressObject->host)) { } elseif($_addressObject->mailbox && $_addressObject->host) {
return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE'));
} else { } else {
return $this->mail_bo->decode_header($_addressObject->mailbox,true); return $this->mail_bo->decode_header($_addressObject->mailbox,true);
@ -1491,10 +1489,10 @@ class mail_compose
$this->sessionData['messageFolder'] = $_folder; $this->sessionData['messageFolder'] = $_folder;
$this->sessionData['isDraft'] = true; $this->sessionData['isDraft'] = true;
foreach((array)$headers['CC'] as $val) { foreach((array)$headers['CC'] as $val) {
$rfcAddr=imap_rfc822_parse_adrlist($val, ''); $rfcAddr=emailadmin_imapbase::parseAddressList($val);
$_rfcAddr = $rfcAddr[0]; $_rfcAddr = $rfcAddr[0];
if ($_rfcAddr->host=='.SYNTAX-ERROR.') continue; if (!$_rfcAddr->valid) continue;
if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
continue; continue;
} }
$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
@ -1512,10 +1510,10 @@ class mail_compose
$this->sessionData['to'][] = $val; $this->sessionData['to'][] = $val;
continue; continue;
} }
$rfcAddr=imap_rfc822_parse_adrlist($val, ''); $rfcAddr=emailadmin_imapbase::parseAddressList($val);
$_rfcAddr = $rfcAddr[0]; $_rfcAddr = $rfcAddr[0];
if ($_rfcAddr->host=='.SYNTAX-ERROR.') continue; if (!$_rfcAddr->valid) continue;
if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) {
continue; continue;
} }
$keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host;
@ -1528,9 +1526,9 @@ class mail_compose
} }
foreach((array)$headers['REPLY-TO'] as $val) { foreach((array)$headers['REPLY-TO'] as $val) {
$rfcAddr=imap_rfc822_parse_adrlist($val, ''); $rfcAddr=emailadmin_imapbase::parseAddressList($val);
$_rfcAddr = $rfcAddr[0]; $_rfcAddr = $rfcAddr[0];
if ($_rfcAddr->host=='.SYNTAX-ERROR.') continue; if (!$_rfcAddr->valid) continue;
if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
continue; continue;
} }
@ -1544,9 +1542,9 @@ class mail_compose
} }
foreach((array)$headers['BCC'] as $val) { foreach((array)$headers['BCC'] as $val) {
$rfcAddr=imap_rfc822_parse_adrlist($val, ''); $rfcAddr=emailadmin_imapbase::parseAddressList($val);
$_rfcAddr = $rfcAddr[0]; $_rfcAddr = $rfcAddr[0];
if ($_rfcAddr->host=='.SYNTAX-ERROR.') continue; if (!$_rfcAddr->valid) continue;
if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) {
continue; continue;
} }
@ -2153,56 +2151,22 @@ class mail_compose
} }
// Expand any mailing lists // Expand any mailing lists
foreach(array('to','cc','bcc') as $field) foreach(array(
'to' => 'AddAddress',
'cc' => 'AddCC',
'bcc' => 'AddBCC',
'replyto' => 'AddReplyto') as $field => $method)
{ {
$_formData[$field] = self::resolveEmailAddressList($_formData[$field]); if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]);
}
foreach((array)$_formData['to'] as $address) { foreach((array)$_formData[$field] as $address)
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address), ''); {
foreach((array)$address_array as $addressObject) { foreach(emailadmin_imapbase::parseAddressList($address) as $addressObject) {
if ($addressObject->host == '.SYNTAX-ERROR.') continue; if (!$addressObject->valid) continue;
$_emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : ''); $_emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$mail_bo->idna2->encode($addressObject->host) : ''); $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$mail_bo->idna2->encode($addressObject->host) : '');
#$emailName = $mail_bo->encodeHeader($addressObject->personal, 'q'); $_mailObject->$method($emailAddress, str_replace(array('@'),' ',($addressObject->personal?$addressObject->personal:$_emailAddress)));
#$_mailObject->AddAddress($emailAddress, $emailName); }
$_mailObject->AddAddress($emailAddress, str_replace(array('@'),' ',($addressObject->personal?$addressObject->personal:$_emailAddress)));
}
}
foreach((array)$_formData['cc'] as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),'');
foreach((array)$address_array as $addressObject) {
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
$_emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$mail_bo->idna2->encode($addressObject->host) : '');
#$emailName = $mail_bo->encodeHeader($addressObject->personal, 'q');
#$_mailObject->AddCC($emailAddress, $emailName);
$_mailObject->AddCC($emailAddress, str_replace(array('@'),' ',($addressObject->personal?$addressObject->personal:$_emailAddress)));
}
}
foreach((array)$_formData['bcc'] as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),'');
foreach((array)$address_array as $addressObject) {
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
$_emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$mail_bo->idna2->encode($addressObject->host) : '');
#$emailName = $mail_bo->encodeHeader($addressObject->personal, 'q');
#$_mailObject->AddBCC($emailAddress, $emailName);
$_mailObject->AddBCC($emailAddress, str_replace(array('@'),' ',($addressObject->personal?$addressObject->personal:$_emailAddress)));
}
}
foreach((array)$_formData['replyto'] as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),'');
foreach((array)$address_array as $addressObject) {
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
$_emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
#$emailName = $mail_bo->encodeHeader($addressObject->personal, 'q');
#$_mailObject->AddBCC($emailAddress, $emailName);
$_mailObject->AddReplyto($emailAddress, str_replace(array('@'),' ',($addressObject->personal?$addressObject->personal:$_emailAddress)));
} }
} }
@ -2491,9 +2455,8 @@ class mail_compose
$this->createMessage($mail, $_formData, $identity); $this->createMessage($mail, $_formData, $identity);
$this->sessionData['bcc'] = self::resolveEmailAddressList($this->sessionData['bcc']); $this->sessionData['bcc'] = self::resolveEmailAddressList($this->sessionData['bcc']);
foreach((array)$this->sessionData['bcc'] as $address) { foreach((array)$this->sessionData['bcc'] as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach(emailadmin_imapbase::parseAddressList($address) as $addressObject) {
foreach((array)$address_array as $addressObject) { $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$mailAddr[] = array($emailAddress, $addressObject->personal); $mailAddr[] = array($emailAddress, $addressObject->personal);
} }
} }
@ -2768,9 +2731,8 @@ class mail_compose
if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') { if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') {
//error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc'])); //error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc']));
foreach((array)$this->sessionData['bcc'] as $address) { foreach((array)$this->sessionData['bcc'] as $address) {
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($address):$address),''); foreach(emailadmin_imapbase::parseAddressList($address) as $addressObject) {
foreach((array)$address_array as $addressObject) { $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : '');
$emailAddress = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$mailAddr[] = array($emailAddress, $addressObject->personal); $mailAddr[] = array($emailAddress, $addressObject->personal);
} }
} }