Al hacer resend de un email en el Message History del Case Information Menu, se despliega dos notice con Undefined index.

Se valido que el elemento que genera el "notice" exista, antes de continuar con la ejecucion del mismo.
This commit is contained in:
marcelo.cuiza
2015-02-11 10:20:48 -04:00
parent 59ccd6e2d4
commit d56bf7133f

View File

@@ -229,15 +229,17 @@ class spoolRun
$this->fileData['envelope_to'] = array (); $this->fileData['envelope_to'] = array ();
$this->fileData["contentTypeIsHtml"] = $bContentTypeIsHtml; $this->fileData["contentTypeIsHtml"] = $bContentTypeIsHtml;
if ($this->config['MESS_ENGINE'] == 'OPENMAIL') { if (array_key_exists('MESS_ENGINE',$this->config)) {
if ($this->config['MESS_SERVER'] != '') { if ($this->config['MESS_ENGINE'] == 'OPENMAIL') {
if (($sAux = @gethostbyaddr( $this->config['MESS_SERVER'] ))) { if ($this->config['MESS_SERVER'] != '') {
$this->fileData['domain'] = $sAux; if (($sAux = @gethostbyaddr( $this->config['MESS_SERVER'] ))) {
$this->fileData['domain'] = $sAux;
} else {
$this->fileData['domain'] = $this->config['MESS_SERVER'];
}
} else { } else {
$this->fileData['domain'] = $this->config['MESS_SERVER']; $this->fileData['domain'] = gethostbyaddr( '127.0.0.1' );
} }
} else {
$this->fileData['domain'] = gethostbyaddr( '127.0.0.1' );
} }
} }
} }
@@ -416,164 +418,166 @@ class spoolRun
private function handleMail () private function handleMail ()
{ {
if (count( $this->fileData['envelope_to'] ) > 0) { if (count( $this->fileData['envelope_to'] ) > 0) {
switch ($this->config['MESS_ENGINE']) { if (array_key_exists('MESS_ENGINE',$this->config)) {
case 'MAIL': switch ($this->config['MESS_ENGINE']) {
case 'PHPMAILER': case 'MAIL':
G::LoadThirdParty( 'phpmailer', 'class.phpmailer' ); case 'PHPMAILER':
G::LoadThirdParty( 'phpmailer', 'class.phpmailer' );
switch ($this->config['MESS_ENGINE']) {
case 'MAIL': switch ($this->config['MESS_ENGINE']) {
$oPHPMailer = new PHPMailer(); case 'MAIL':
$oPHPMailer->Mailer = 'mail'; $oPHPMailer = new PHPMailer();
break; $oPHPMailer->Mailer = 'mail';
case 'PHPMAILER': break;
$oPHPMailer = new PHPMailer( true ); case 'PHPMAILER':
$oPHPMailer->Mailer = 'smtp'; $oPHPMailer = new PHPMailer( true );
break; $oPHPMailer->Mailer = 'smtp';
} break;
$oPHPMailer->SMTPAuth = (isset( $this->config['SMTPAuth'] ) ? $this->config['SMTPAuth'] : '');
switch ($this->config['MESS_ENGINE']) {
case 'MAIL':
break;
case 'PHPMAILER':
//Posible Options for SMTPSecure are: "", "ssl" or "tls"
if (isset( $this->config['SMTPSecure'] ) && preg_match( '/^(ssl|tls)$/', $this->config['SMTPSecure'] )) {
$oPHPMailer->SMTPSecure = $this->config['SMTPSecure'];
}
break;
}
$oPHPMailer->CharSet = "UTF-8";
$oPHPMailer->Encoding = "8bit";
$oPHPMailer->Host = $this->config['MESS_SERVER'];
$oPHPMailer->Port = $this->config['MESS_PORT'];
$oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
$oPHPMailer->Password = $this->config['MESS_PASSWORD'];
$oPHPMailer->From = $this->fileData['from_email'];
$oPHPMailer->FromName = utf8_decode( $this->fileData['from_name'] );
if (isset($this->fileData['reply_to'])) {
if ($this->fileData['reply_to'] != '') {
$oPHPMailer->AddReplyTo($this->fileData['reply_to'], $this->fileData['reply_to_name']);
} }
}
$oPHPMailer->SMTPAuth = (isset( $this->config['SMTPAuth'] ) ? $this->config['SMTPAuth'] : '');
$msSubject = $this->fileData['subject'];
switch ($this->config['MESS_ENGINE']) {
if (! (mb_detect_encoding( $msSubject, "UTF-8" ) == "UTF-8")) { case 'MAIL':
$msSubject = utf8_encode( $msSubject ); break;
} case 'PHPMAILER':
//Posible Options for SMTPSecure are: "", "ssl" or "tls"
$oPHPMailer->Subject = $msSubject; if (isset( $this->config['SMTPSecure'] ) && preg_match( '/^(ssl|tls)$/', $this->config['SMTPSecure'] )) {
$oPHPMailer->SMTPSecure = $this->config['SMTPSecure'];
$msBody = $this->fileData['body']; }
break;
if (! (mb_detect_encoding( $msBody, "UTF-8" ) == "UTF-8")) { }
$msBody = utf8_encode( $msBody );
} $oPHPMailer->CharSet = "UTF-8";
$oPHPMailer->Encoding = "8bit";
$oPHPMailer->Body = $msBody; $oPHPMailer->Host = $this->config['MESS_SERVER'];
$oPHPMailer->Port = $this->config['MESS_PORT'];
$attachment = @unserialize($this->fileData['attachments']); $oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
if ($attachment === false) { $oPHPMailer->Password = $this->config['MESS_PASSWORD'];
$attachment = $this->fileData['attachments']; $oPHPMailer->From = $this->fileData['from_email'];
} $oPHPMailer->FromName = utf8_decode( $this->fileData['from_name'] );
if (is_array($attachment)) { if (isset($this->fileData['reply_to'])) {
foreach ($attachment as $key => $fileAttach) { if ($this->fileData['reply_to'] != '') {
if (file_exists( $fileAttach )) { $oPHPMailer->AddReplyTo($this->fileData['reply_to'], $this->fileData['reply_to_name']);
$oPHPMailer->AddAttachment( $fileAttach, is_int( $key ) ? '' : $key );
} }
} }
}
$msSubject = $this->fileData['subject'];
foreach ($this->fileData['envelope_to'] as $sEmail) {
if (strpos( $sEmail, '<' ) !== false) { if (! (mb_detect_encoding( $msSubject, "UTF-8" ) == "UTF-8")) {
preg_match( $this->longMailEreg, $sEmail, $matches ); $msSubject = utf8_encode( $msSubject );
$sTo = trim( $matches[3] );
$sToName = trim( $matches[1] );
$oPHPMailer->AddAddress( $sTo, $sToName );
} else {
$oPHPMailer->AddAddress( $sEmail );
} }
}
$oPHPMailer->Subject = $msSubject;
//CC
foreach ($this->fileData['envelope_cc'] as $sEmail) { $msBody = $this->fileData['body'];
if (strpos( $sEmail, '<' ) !== false) {
preg_match( $this->longMailEreg, $sEmail, $matches ); if (! (mb_detect_encoding( $msBody, "UTF-8" ) == "UTF-8")) {
$sTo = trim( $matches[3] ); $msBody = utf8_encode( $msBody );
$sToName = trim( $matches[1] );
$oPHPMailer->AddCC( $sTo, $sToName );
} else {
$oPHPMailer->AddCC( $sEmail );
} }
}
$oPHPMailer->Body = $msBody;
//BCC
foreach ($this->fileData['envelope_bcc'] as $sEmail) { $attachment = @unserialize($this->fileData['attachments']);
if (strpos( $sEmail, '<' ) !== false) { if ($attachment === false) {
preg_match( $this->longMailEreg, $sEmail, $matches ); $attachment = $this->fileData['attachments'];
$sTo = trim( $matches[3] );
$sToName = trim( $matches[1] );
$oPHPMailer->AddBCC( $sTo, $sToName );
} else {
$oPHPMailer->AddBCC( $sEmail );
} }
} if (is_array($attachment)) {
foreach ($attachment as $key => $fileAttach) {
$oPHPMailer->IsHTML($this->fileData["contentTypeIsHtml"]); if (file_exists( $fileAttach )) {
$oPHPMailer->AddAttachment( $fileAttach, is_int( $key ) ? '' : $key );
if ( $this->config['MESS_ENGINE'] == 'MAIL') { }
$oPHPMailer->WordWrap = 300; }
}
if ($oPHPMailer->Send()) {
$this->error = '';
$this->status = 'sent';
} else {
$this->error = $oPHPMailer->ErrorInfo;
$this->status = 'failed';
}
break;
case 'OPENMAIL':
G::LoadClass( 'package' );
G::LoadClass( 'smtp' );
$pack = new package( $this->fileData );
$header = $pack->returnHeader();
$body = $pack->returnBody();
$send = new smtp();
$send->setServer( $this->config['MESS_SERVER'] );
$send->setPort( $this->config['MESS_PORT'] );
$send->setUsername( $this->config['MESS_ACCOUNT'] );
$passwd = $this->config['MESS_PASSWORD'];
$passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' );
$auxPass = explode( 'hash:', $passwdDec );
if (count( $auxPass ) > 1) {
if (count( $auxPass ) == 2) {
$passwd = $auxPass[1];
} else {
array_shift( $auxPass );
$passwd = implode( '', $auxPass );
} }
}
foreach ($this->fileData['envelope_to'] as $sEmail) {
$this->config['MESS_PASSWORD'] = $passwd; if (strpos( $sEmail, '<' ) !== false) {
$send->setPassword( $this->config['MESS_PASSWORD'] ); preg_match( $this->longMailEreg, $sEmail, $matches );
$send->setReturnPath( $this->fileData['from_email'] ); $sTo = trim( $matches[3] );
$send->setHeaders( $header ); $sToName = trim( $matches[1] );
$send->setBody( $body ); $oPHPMailer->AddAddress( $sTo, $sToName );
$send->setEnvelopeTo( $this->fileData['envelope_to'] ); } else {
if ($send->sendMessage()) { $oPHPMailer->AddAddress( $sEmail );
$this->error = ''; }
$this->status = 'sent'; }
} else {
$this->error = implode( ', ', $send->returnErrors() ); //CC
$this->status = 'failed'; foreach ($this->fileData['envelope_cc'] as $sEmail) {
} if (strpos( $sEmail, '<' ) !== false) {
break; preg_match( $this->longMailEreg, $sEmail, $matches );
$sTo = trim( $matches[3] );
$sToName = trim( $matches[1] );
$oPHPMailer->AddCC( $sTo, $sToName );
} else {
$oPHPMailer->AddCC( $sEmail );
}
}
//BCC
foreach ($this->fileData['envelope_bcc'] as $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($this->fileData["contentTypeIsHtml"]);
if ( $this->config['MESS_ENGINE'] == 'MAIL') {
$oPHPMailer->WordWrap = 300;
}
if ($oPHPMailer->Send()) {
$this->error = '';
$this->status = 'sent';
} else {
$this->error = $oPHPMailer->ErrorInfo;
$this->status = 'failed';
}
break;
case 'OPENMAIL':
G::LoadClass( 'package' );
G::LoadClass( 'smtp' );
$pack = new package( $this->fileData );
$header = $pack->returnHeader();
$body = $pack->returnBody();
$send = new smtp();
$send->setServer( $this->config['MESS_SERVER'] );
$send->setPort( $this->config['MESS_PORT'] );
$send->setUsername( $this->config['MESS_ACCOUNT'] );
$passwd = $this->config['MESS_PASSWORD'];
$passwdDec = G::decrypt( $passwd, 'EMAILENCRYPT' );
$auxPass = explode( 'hash:', $passwdDec );
if (count( $auxPass ) > 1) {
if (count( $auxPass ) == 2) {
$passwd = $auxPass[1];
} else {
array_shift( $auxPass );
$passwd = implode( '', $auxPass );
}
}
$this->config['MESS_PASSWORD'] = $passwd;
$send->setPassword( $this->config['MESS_PASSWORD'] );
$send->setReturnPath( $this->fileData['from_email'] );
$send->setHeaders( $header );
$send->setBody( $body );
$send->setEnvelopeTo( $this->fileData['envelope_to'] );
if ($send->sendMessage()) {
$this->error = '';
$this->status = 'sent';
} else {
$this->error = implode( ', ', $send->returnErrors() );
$this->status = 'failed';
}
break;
}
} }
} }
} }