BUG 9479 "The email send contains special characters \n\r" SOLVED
- The email send contains special characters "\n\r" - This bug could not be replicated, there was improvement in the delivery of mails (for configurations with SMTP (PHPMailer) and Mail (PHP))
This commit is contained in:
@@ -321,70 +321,35 @@ class spoolRun {
|
||||
*/
|
||||
private function handleMail() {
|
||||
if( count($this->fileData['envelope_to']) > 0 ) {
|
||||
switch( $this->config['MESS_ENGINE'] ) {
|
||||
switch ($this->config['MESS_ENGINE']) {
|
||||
case 'MAIL':
|
||||
G::LoadThirdParty('phpmailer', 'class.phpmailer');
|
||||
$oPHPMailer = new PHPMailer();
|
||||
$oPHPMailer->Mailer = 'mail';
|
||||
$oPHPMailer->SMTPAuth = (isset($this->config['SMTPAuth']) ? $this->config['SMTPAuth'] : '');
|
||||
$oPHPMailer->Host = $this->config['MESS_SERVER'];
|
||||
$oPHPMailer->Port = $this->config['MESS_PORT'];
|
||||
$oPHPMailer->Username = $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;
|
||||
$oPHPMailer->Password = $this->config['MESS_PASSWORD'];
|
||||
$oPHPMailer->From = $this->fileData['from_email'];
|
||||
$oPHPMailer->FromName = utf8_decode($this->fileData['from_name']);
|
||||
$oPHPMailer->Subject = utf8_decode($this->fileData['subject']);
|
||||
$oPHPMailer->Body = utf8_decode($this->fileData['body']);
|
||||
if(is_array($this->fileData['attachments'])){
|
||||
foreach($this->fileData['attachments'] as $key => $fileAttach){
|
||||
$oPHPMailer->AddAttachment($fileAttach, is_int($key) ? '' : $key);
|
||||
}
|
||||
}
|
||||
foreach( $this->fileData['envelope_to'] as $sEmail ) {
|
||||
if( strpos($sEmail, '<') !== false ) {
|
||||
preg_match($this->longMailEreg, $sEmail, $matches);
|
||||
$sTo = trim($matches[3]);
|
||||
$sToName = trim($matches[1]);
|
||||
$oPHPMailer->AddAddress($sTo, $sToName);
|
||||
} else {
|
||||
$oPHPMailer->AddAddress($sEmail);
|
||||
}
|
||||
}
|
||||
|
||||
$oPHPMailer->IsHTML(true);
|
||||
if( $oPHPMailer->Send() ) {
|
||||
$this->error = '';
|
||||
$this->status = 'sent';
|
||||
} else {
|
||||
$this->error = $oPHPMailer->ErrorInfo;
|
||||
$this->status = 'failed';
|
||||
}
|
||||
break;
|
||||
case 'PHPMAILER':
|
||||
G::LoadThirdParty('phpmailer', 'class.phpmailer');
|
||||
$oPHPMailer = new PHPMailer(true);
|
||||
$oPHPMailer->Mailer = 'smtp';
|
||||
|
||||
switch($this->config['MESS_ENGINE']) {
|
||||
case 'MAIL':
|
||||
$oPHPMailer = new PHPMailer();
|
||||
$oPHPMailer->Mailer = 'mail';
|
||||
break;
|
||||
case 'PHPMAILER':
|
||||
$oPHPMailer = new PHPMailer(true);
|
||||
$oPHPMailer->Mailer = 'smtp';
|
||||
break;
|
||||
}
|
||||
|
||||
$oPHPMailer->SMTPAuth = (isset($this->config['SMTPAuth']) ? $this->config['SMTPAuth'] : '');
|
||||
|
||||
|
||||
/**
|
||||
* 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'];
|
||||
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'];
|
||||
@@ -393,27 +358,35 @@ class spoolRun {
|
||||
$passwd = $this->config['MESS_PASSWORD'];
|
||||
$passwdDec = G::decrypt($passwd,'EMAILENCRYPT');
|
||||
$auxPass = explode('hash:', $passwdDec);
|
||||
if (count($auxPass) > 1) {
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
if (count($auxPass) == 2) {
|
||||
$passwd = $auxPass[1];
|
||||
} else {
|
||||
array_shift($auxPass);
|
||||
$passwd = implode('', $auxPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->config['MESS_PASSWORD'] = $passwd;
|
||||
$oPHPMailer->Password = $this->config['MESS_PASSWORD'];
|
||||
$oPHPMailer->From = $this->fileData['from_email'];
|
||||
$oPHPMailer->FromName = utf8_decode($this->fileData['from_name']);
|
||||
|
||||
$msSubject = $this->fileData['subject'];
|
||||
|
||||
if(!(mb_detect_encoding($msSubject, "UTF-8") == "UTF-8")) {
|
||||
$msSubject = utf8_encode($msSubject);
|
||||
}
|
||||
|
||||
$oPHPMailer->Subject = $msSubject;
|
||||
|
||||
$msBody = $this->fileData['body'];
|
||||
|
||||
if(!(mb_detect_encoding($msBody, "UTF-8") == "UTF-8")) {
|
||||
$msBody = utf8_encode($msBody);
|
||||
}
|
||||
|
||||
$oPHPMailer->Body = $msBody;
|
||||
|
||||
if(is_array($this->fileData['attachments'])){
|
||||
@@ -421,8 +394,8 @@ class spoolRun {
|
||||
$oPHPMailer->AddAttachment($fileAttach, is_int($key) ? '' : $key);
|
||||
}
|
||||
}
|
||||
foreach( $this->fileData['envelope_to'] as $sEmail ) {
|
||||
$evalMail = strpos($sEmail, '<');
|
||||
|
||||
foreach ($this->fileData['envelope_to'] as $sEmail) {
|
||||
if( strpos($sEmail, '<') !== false ) {
|
||||
preg_match($this->longMailEreg, $sEmail, $matches);
|
||||
$sTo = trim($matches[3]);
|
||||
@@ -434,10 +407,8 @@ class spoolRun {
|
||||
}
|
||||
|
||||
//CC
|
||||
foreach( $this->fileData['envelope_cc'] as $sEmail ) {
|
||||
$evalMail = strpos($sEmail, '<');
|
||||
|
||||
if( strpos($sEmail, '<') !== false ) {
|
||||
foreach ($this->fileData['envelope_cc'] as $sEmail) {
|
||||
if(strpos($sEmail, '<') !== false) {
|
||||
preg_match($this->longMailEreg, $sEmail, $matches);
|
||||
$sTo = trim($matches[3]);
|
||||
$sToName = trim($matches[1]);
|
||||
@@ -448,10 +419,8 @@ class spoolRun {
|
||||
}
|
||||
|
||||
//BCC
|
||||
foreach( $this->fileData['envelope_bcc'] as $sEmail ) {
|
||||
$evalMail = strpos($sEmail, '<');
|
||||
|
||||
if( strpos($sEmail, '<') !== false ) {
|
||||
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]);
|
||||
@@ -461,14 +430,14 @@ class spoolRun {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$oPHPMailer->IsHTML(true);
|
||||
if( $oPHPMailer->Send() ) {
|
||||
$this->error = '';
|
||||
$this->status = 'sent';
|
||||
|
||||
if($oPHPMailer->Send()) {
|
||||
$this->error = '';
|
||||
$this->status = 'sent';
|
||||
} else {
|
||||
$this->error = $oPHPMailer->ErrorInfo;
|
||||
$this->status = 'failed';
|
||||
$this->error = $oPHPMailer->ErrorInfo;
|
||||
$this->status = 'failed';
|
||||
}
|
||||
break;
|
||||
case 'OPENMAIL':
|
||||
@@ -485,14 +454,16 @@ class spoolRun {
|
||||
$passwd = $this->config['MESS_PASSWORD'];
|
||||
$passwdDec = G::decrypt($passwd,'EMAILENCRYPT');
|
||||
$auxPass = explode('hash:', $passwdDec);
|
||||
if (count($auxPass) > 1) {
|
||||
|
||||
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']);
|
||||
@@ -527,14 +498,16 @@ class spoolRun {
|
||||
$passwd = $aConfiguration["MESS_PASSWORD"];
|
||||
$passwdDec = G::decrypt($passwd,"EMAILENCRYPT");
|
||||
$auxPass = explode('hash:', $passwdDec);
|
||||
if (count($auxPass) > 1) {
|
||||
|
||||
if (count($auxPass) > 1) {
|
||||
if (count($auxPass) == 2) {
|
||||
$passwd = $auxPass[1];
|
||||
} else {
|
||||
array_shift($auxPass);
|
||||
$passwd = implode('', $auxPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aConfiguration["MESS_PASSWORD"] = $passwd;
|
||||
|
||||
if ($aConfiguration["MESS_ENABLED"] == "1") {
|
||||
|
||||
Reference in New Issue
Block a user