From 9b49396435dcc4f2bbee75099331d67ce3d9a2c0 Mon Sep 17 00:00:00 2001 From: Alvaro Campos Date: Wed, 19 Jan 2011 15:19:32 +0000 Subject: [PATCH] Fixed problem with CC and BCC address in the function PMFSendMessage --- workflow/engine/classes/class.spool.php | 61 +++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/workflow/engine/classes/class.spool.php b/workflow/engine/classes/class.spool.php index 3fc932b6f..92c8cc1a5 100755 --- a/workflow/engine/classes/class.spool.php +++ b/workflow/engine/classes/class.spool.php @@ -247,13 +247,15 @@ class spoolRun { */ private function handleEnvelopeTo() { $hold = array (); + $holdcc = array (); + $holdbcc = array (); $text = trim($this->fileData['to']); if( isset($this->fileData['cc']) && trim($this->fileData['cc']) != '' ) { - $text .= ',' . trim($this->fileData['cc']); + $textcc = trim($this->fileData['cc']); } - + if( isset($this->fileData['bcc']) && trim($this->fileData['bcc']) != '' ) { - $text .= ',' . trim($this->fileData['bcc']); + $textbcc = trim($this->fileData['bcc']); } if( false !== (strpos($text, ',')) ) { @@ -267,6 +269,32 @@ class spoolRun { } else { $this->fileData['envelope_to'][] = "$text"; } + //for cc add by alvaro + if( false !== (strpos($textcc, ',')) ) { + $holdcc = explode(',', $textcc); + + foreach( $holdcc as $valcc ) { + if( strlen($valcc) > 0 ) { + $this->fileData['envelope_cc'][] = "$valcc"; + } + } + } else { + $this->fileData['envelope_cc'][] = "$textcc"; + } + //forbcc add by alvaro + if( false !== (strpos($textbcc, ',')) ) { + $holdbcc = explode(',', $textbcc); + + foreach( $holdbcc as $valbcc ) { + if( strlen($valbcc) > 0 ) { + $this->fileData['envelope_bcc'][] = "$valbcc"; + } + } + } else { + $this->fileData['envelope_bcc'][] = "$textbcc"; + } + + } /** @@ -337,6 +365,33 @@ class spoolRun { $oPHPMailer->AddAddress($sEmail); } } + //add cc add by alvaro + foreach( $this->fileData['envelope_cc'] as $sEmail ) { + $evalMail = strpos($sEmail, '<'); + + if( strpos($sEmail, '<') !== false ) { + preg_match($this->longMailEreg, $sEmail, $matches); + $sTo = trim($matches[3]); + $sToName = trim($matches[1]); + $oPHPMailer->AddCC($sTo, $sToName); + } else { + $oPHPMailer->AddCC($sEmail); + } + } + //add bcc add by alvaro + foreach( $this->fileData['envelope_bcc'] as $sEmail ) { + $evalMail = strpos($sEmail, '<'); + + if( strpos($sEmail, '<') !== false ) { + preg_match($this->longMailEreg, $sEmail, $matches); + $sTo = trim($matches[3]); + $sToName = trim($matches[1]); + $oPHPMailer->AddBCC($sTo, $sToName); + } else { + $oPHPMailer->AddBCC($sEmail); + } + } + $oPHPMailer->IsHTML(true); if( $oPHPMailer->Send() ) {