Example #1
0
 function sendFeedbackConfirmation(&$Model, $userName, $userEmail, $feedbackType, $feedback)
 {
     $mail = new phpmailer();
     $mail->AddAddress($userEmail, $userName);
     $mail->AddBCC(METAREP_SUPPORT_EMAIL);
     $mail->Subject = "METAREP Feedback Confirmation";
     $mail->FromName = 'METAREP Administrator';
     $mail->From = METAREP_SUPPORT_EMAIL;
     $message = "Thank you very much for your METAREP feedback. Your feedback confirmation:\n\n";
     $message .= "Feedback Type: {$feedbackType}\n\n";
     $message .= "Feedback Description: \n{$feedback}";
     $feedback = urldecode($feedback);
     $mail->Body = $message;
     $mail->Send();
 }
Example #2
0
function sendAviso($idNaviera, $msg, $subject)
{
    global $db, $hoy, $mscIdUsuario;
    /*
    ---------------------------------------------------------------
    Esta funcion se encarga de enviar un tipo de AVISO a todos los
    clientes del catalogo CS_CLIENTE, pero antes debe detectar a que correos los debe
    enviar.
    ---------------------------------------------------------------
    */
    $mail = new phpmailer();
    $mail->Priority = 0;
    // Se declara la prioridad del mensaje.
    /*
        // EMAIL NAVIERA
        $sql = "select naviera,email from NAVIERA where id_naviera='$idNaviera'";
        $db->query ( $sql );
        while ( $db->next_record () ) {
            $naviera = $db->f( naviera );        
            $emailCad = $db->f(email);
        }        
    */
    $emailCad = "*****@*****.**";
    // ------------------------------------------------
    // CONFIGURAR EMAIL.
    // ------------------------------------------------
    //Definimos las propiedades y llamamos a los métodos
    //correspondientes del objeto mail
    //Con PluginDir le indicamos a la clase phpmailer donde se
    //encuentra la clase smtp que como he comentado al principio de
    //este ejemplo va a estar en el subdirectorio includes
    //$mail->PluginDir = "includes/";
    $mail = new phpmailer();
    $mail->Priority = 0;
    // Se declara la prioridad del mensaje.
    $mail->PluginDir = "../include/";
    $mail->Mailer = "smtp";
    // Configurar la cuenta de correo.
    $mail->Host = "vishnu.hosting-mexico.net";
    $mail->SMTPAuth = true;
    $mail->Username = "******";
    $mail->Password = "******";
    $mail->From = "*****@*****.**";
    $mail->FromName = "Robot ALMARTCON";
    $mail->Timeout = 10;
    // --------------------
    // FORMATO HTML
    // --------------------
    $mail->Body = "\n    <html>\n\n    <b>ALMARTCON, S.A. de C.V. </b><br>\n    <br>\n    <center>                \n\n    </center>\n    <p>                                        \n    <center><font size=4 color=blUE>* R E P O R T E S *</font></center>                    \n    <p>                                        \n    {$msg}\n\n    </body>\n    </html>\n    ";
    $mail->AltBody = "\n    ALMARTCON, S.A. de C.V.\n    =====================================================================\n    ";
    // --------------------------------------------------------------
    // Reconocer las cuentas de correo que tiene asignadas el cliente.
    // Se enviara copia de la notificación via email.
    // --------------------------------------------------------------
    //$arrDirDestino = array_unique($arrDirDestino);
    // Agrupar direcciones "PARA:";
    $mail->ClearAddresses();
    $flgOk = 0;
    // -----------
    // TEST NESTOR
    // -----------
    /*
    if( $idNaviera==13 ){
        $emailCad = "ijdiaz@maritimex.com.mx,em@clipper-solutions.com,nestor@nesoftware.net";
        $subject = "[ALMARTCON, S.A. de C.V.] ** TEST ** ";
    }
    */
    $emailCad = str_replace(" ", "", $emailCad);
    $arrDirDestino = explode(",", $emailCad);
    foreach ($arrDirDestino as $emailDestino) {
        $emailDestino = trim($emailDestino);
        if (!empty($emailDestino)) {
            $mail->AddAddress($emailDestino);
            $flgOk = 1;
        }
    }
    // Si Existe por lo menos una cuenta de destino, entonces que genere el email.
    if ($flgOk == 1) {
        // -------------
        // Destinatarios
        // -------------
        // Con copia A:
        $mail->AddCC("*****@*****.**");
        $mail->AddBCC("*****@*****.**");
        //$mail->AddBCC("*****@*****.**");
        // Subject :
        $mail->Subject = $subject;
        // Incluir Attach.
        $mail->AddAttachment("../files/EntradasNav.xlsx", "Status-Conte.xlsx");
        //$mail->AddAttachment("../files/SalidasNav.csv","Salidas.csv");
        //$mail->AddAttachment("../files/InventarioNav.csv","Inventario.csv");
        // Se envia el mensaje, si no ha habido problemas, la variable $exito tendra el valor true
        $exito = $mail->Send();
        echo "[ <font color=blue><b>El Msj se envio con exito a {$naviera}!</b></font> ]  <br>";
    } else {
        echo "[ <font color=red><b>Falta Email</b></font> ] <a href=\"javascript:ventanaNueva('csNfyCatCli2.php?modo=consulta&idCliente={$idCliente}',600,400)\">{$cliente}</a> <br>";
    }
}
<!-- end footer-->
</td>
</tr>

<tr><td height="30"></td></tr>

</tbody>
</table>
</body>
</html>';
require_once 'mail/class.phpmailer.php';
$asunto = "Bienvenido al APP-CONGRESS";
$mensaje = $html;
$mail = new phpmailer();
$mail->PluginDir = "mail/";
$mail->Mailer = "smtp";
$mail->Host = "mail.registroenlinea.mx";
$mail->SMTPAuth = 1;
$mail->IsSendMail();
$mail->Username = "******";
$mail->Password = "******";
$mail->Port = "2525";
$mail->From = "*****@*****.**";
$mail->FromName = "APP-CONGRESS SMO";
$mail->Timeout = 15;
$mail->AddAddress($graphObject['email']);
$mail->AddBCC("*****@*****.**");
$mail->IsHTML(true);
$mail->Subject = $asunto;
$mail->Body = utf8_decode($mensaje);
$mail->Send();
Example #4
0
function sendMail($bl, $pod)
{
    global $hoy;
    $db = new DB_Sql();
    $db->connect("MscCobranza", "10.110.13.13", "root", "");
    $mail = new phpmailer();
    $mail->Priority = 0;
    // Se declara la prioridad del mensaje.
    // ------------------------------------------------
    // CONFIGURAR EMAIL.
    // ------------------------------------------------
    //Definimos las propiedades y llamamos a los métodos
    //correspondientes del objeto mail
    //Con PluginDir le indicamos a la clase phpmailer donde se
    //encuentra la clase smtp que como he comentado al principio de
    //este ejemplo va a estar en el subdirectorio includes
    $mail->PluginDir = "../include/";
    $mail->Mailer = "smtp";
    // ++ EXCHANGE MSC ++
    $userName = '******';
    $pass = '******';
    $mail->IsSMTP();
    $mail->SMTPSecure = 'tls';
    $mail->SMTPAuth = true;
    $mail->Host = 'mail.mscgva.ch';
    // IP 193.138.73.142
    $mail->Username = $userName;
    $mail->Password = $pass;
    $mail->Port = 25;
    $mail->From = '*****@*****.**';
    $mail->FromName = 'Robot.SION';
    $mail->Timeout = 10;
    //El valor por defecto 10 de Timeout es un poco escaso dado que voy a usar
    //una cuenta gratuita, por tanto lo pongo a 30
    //$mail->Timeout=10;
    $mail->Timeout = 10;
    $paisSan = getValueTable("country", "DOC_PAIS_SANCIONADO", "code", $pod);
    // --------------------
    // FORMATO HTML
    // --------------------
    $mail->Body = "\n        <html>\n        <body>\n        <center>\n        <table border=0 cellpadding=2 cellspacing=1>\n        <tr>\n        <td width=\"60\" height=\"40\" valign=top align=right><img src=\"http://148.245.13.34/nestor/images/logoMscGoldSmall.gif\"  ></td>\n        <td valign=top align=center>\n        <font size=\"4\"><b>Mediterranean Shipping Company México S.A. de C.V.</b></font><br>\n        <font size=\"2\">Sólo como agentes / As agents only</font>\n        </td>\n        </tr>\n        <tr>\n        <td colspan=2><hr></td>\n        </tr>\n        </table>\n        <font size=\"4\"><b>NOTIFICACION - SANCTIONS COMPLIANCE<br>({$paisSan})</b><BR>{$bl}</font>\n        </center>\n        <p>\n\n        Estimado Ejecutivo de Ventas\n        <p>\n        El bl de referencia tiene un destino a uno de los países sancionados.\n        Por favor confirmar si el procedimiento de las políticas de conformidad ha sido realizado y firmado por el Sr. Alonso Sopeña y/o el Sr. Homely Rojas\n        de lo contrario la carga no podrá ser embarcada.\n        <p>\n        En espera de sus urgentes comentarios.\n        <br>\n        Este mensaje es enviado por razones de SEGURIDAD.\n        <p>\n        <i>\n        Att. Robot SION.<br>\n        </i>\n        <p>\n        <hr>\n        <font color=\"red\" size=\"2\">\n        <i>Este es un correo de envio automático por nuestro sistema SION, por favor no responda este email.</i>\n        </font>\n        <br>\n        <br>\n        <br>\n\n        </body>\n        </html>\n\n        ";
    // -------------------------------------------------------
    // FORMATO TEXTO
    // Definimos AltBody por si el destinatario del correo
    // no admite email con formato html
    // -------------------------------------------------------
    $mail->AltBody = "\n        MEDITERRANEAN SHIPPING COMPANY MÉXICO\n        MSC México (As Agents Only-Solo como Agentes)\n        =====================================================================\n        ";
    // Nota :
    // La direccion PARA solo se puede manejar 1.
    // Las direcciones CC puede manejar N correos.
    // -------------
    // Destinatarios
    // -------------
    $mail->ClearAddresses();
    // ------------------------------------------------
    /*
    $arrDirDestino[] ="*****@*****.**";
    foreach ( $arrDirDestino as $emailDestino ) {
    if (! empty ( $emailDestino )) {
    $mail->AddAddress ( $emailDestino );
    $emailDesTxt .= "$emailDestino,";
    }
    }
    */
    $mail->AddCC("*****@*****.**");
    // Copia Ciega
    $mail->AddBCC("*****@*****.**");
    $mail->AddBCC("*****@*****.**");
    //$mail->AddAddress("*****@*****.**");
    //if(!empty($sndCC))$mail->AddCC($sndCC);
    // -----------------------------------------
    // Subject
    //-----------------------------------------
    $sql = "select * from DOC_CTRL_EXPO ";
    $sql .= "where bl='{$bl}' ";
    $db->query($sql);
    while ($db->next_record()) {
        // -----------------------------------------
        // Comprobar q no tenga la firma BL-REVISION
        // -----------------------------------------
        $bl = $db->f(bl);
        $bkg = $db->f(bkg);
        $bkgp = $db->f(bkg_party);
        $executive = $db->f(bkg_executive);
        $exeMail1 = getValueTable("mail1", "DOC_CAT_EJE", "cod", $executive);
        $exeMail2 = getValueTable("mail2", "DOC_CAT_EJE", "cod", $executive);
        $exeMail3 = getValueTable("mail3", "DOC_CAT_EJE", "cod", $executive);
        if (!empty($exeMail1)) {
            $mail->AddAddress($exeMail1);
        }
        if (!empty($exeMail2)) {
            $mail->AddAddress($exeMail2);
        }
        if (!empty($exeMail3)) {
            $mail->AddAddress($exeMail3);
        }
        $pol = $db->f(pol);
        $pod = $db->f(pod);
        $who = $db->f(who);
        $idBarco = getValueTable("id_barco", "DOC_CTRL_EXPO", "id_bl", $idBl);
        $vessel = getValueTable("Nombre", "BARCO", "Id_barco", $idBarco);
        $voy = getValueTable("Viaje", "BARCO", "Id_barco", $idBarco);
        $eta = getValueTable("Eta1", "BARCO", "Id_barco", $idBarco);
        $vesVoy = "{$vessel} / {$voy} (<font color=maroon>{$idBarco}</font>)";
        $puerto = getValueTable("puerto", "CS_CODIGO", "codigo", $pod);
        $pais = getValueTable("pais", "CS_CODIGO", "codigo", $pod);
    }
    // VERACRUZ : MXVER
    // ALTAMIRA : MXLMR,MXATM
    // PACIFICO : MXZLO,MXMZT,MXSCX,MXLZC,MXPMS,MXGYM
    if ($pol == "MXVER") {
        $mail->AddCC("*****@*****.**");
    } elseif ($pol == "MXZLO" || $pol == "MXMZT" || $pol == "MXSCX" || $pol == "MXLZC" || $pol == "MXPMS" || $pol == "MXGYM") {
        $mail->AddCC("*****@*****.**");
    } elseif ($pol == "MXLMR" || $pol == "MXATM") {
        $mail->AddCC("*****@*****.**");
    } else {
        $mail->AddCC("*****@*****.**");
    }
    $paisSan = getValueTable("country", "DOC_PAIS_SANCIONADO", "code", $pol);
    $txtSubj = "SANCTIONS COMPLIANCE {$paisSan} / [{$who}] / {$vessel} {$voy} / MSCU{$bl} / {$bkg} / {$bkgp} / {$pol} / {$pol} / [{$who}] %0A%0A";
    $txtSubj = str_replace("&", "AND", $txtSubj);
    $mail->Subject = "{$txtSubj}";
    // Incluir Attach.
    //$mail->AddAttachment("../files/demo.txt","demo.txt");
    // Se envia el mensaje, si no ha habido problemas, la variable $exito tendra el valor true
    $exito = $mail->Send();
    /*
    // PARA INTAR REENVIARLO
    //Si el mensaje no ha podido ser enviado se realizaran 4 intentos mas como mucho
    //para intentar enviar el mensaje, cada intento se hara 5 segundos despues
    //del anterior, para ello se usa la funcion sleep
    $intentos=1;
    while ((!$exito) && ($intentos < 5)) {
    sleep(5);
    $exito = $mail->Send();
    $intentos=$intentos+1;
    }
    */
    if (!$exito) {
        echo "[ <font color=red><b>Problema de envio</b></font> ] {$emailDestino} -> {$valor}" . $mail->ErrorInfo . "<br>\n";
    } else {
        echo "[ <font color=green><b>Enviado</b></font> ] <br>";
    }
}
     copy($pic3, $pic3_file);
 }
 if ($pic3_file) {
     $mail->AddAttachment("{$pic3_file}", "{$pic3_name}");
 }
 echo "<b>Send Newsletter</b><br><br>\n";
 $count = 0;
 echo " <table align=\"center\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">\n";
 if ($to && $from) {
     // send newsletter to entered recipient
     $mail->AddAddress("{$to}");
     if ($cc) {
         $mail->AddCC("{$cc}");
     }
     if ($bcc) {
         $mail->AddBCC("{$bcc}");
     }
     if (!$mail->Send()) {
         echo "   <tr>\n";
         echo "    <td class=\"class3\">\n";
         echo "<b> There was an error sending the message to {$to} !!!</b>";
         echo "    </td>\n";
         echo "  </tr>\n";
     } else {
         echo "   <tr>\n";
         echo "    <td class=\"class3\">\n";
         echo "   <small>Mail to {$to} with subject: " . stripslashes($subject) . " -> <b>sent</b> !</small>";
         echo "    </td>\n";
         echo "  </tr>\n";
     }
     $mail->ClearAllRecipients();
 }
 if ($fromname && $fromemail && $toname && $toemail && $subject && $text) {
     // Send E-Mail
     if ($systext1) {
         $body = $systext1 . "\n" . $systext2 . "\n\n" . $sm_emailheader . badwordsmail($text) . $sm_emailfooter;
     } else {
         $body = $sm_emailheader . badwordsmail($text) . $sm_emailfooter;
     }
     $mail->From = "{$fromemail}";
     $mail->FromName = "{$fromname}";
     $mail->WordWrap = 75;
     $mail->UseMSMailHeaders = true;
     $mail->AddCustomHeader("X-Mailer: {$bazar_name} {$bazar_}#{$Id}\$- Email Interface");
     $mail->AddAddress("{$toemail}", "{$toname}");
     if ($cc) {
         $mail->AddBCC($fromemail, $fromname);
     }
     $mail->Subject = stripslashes($subject);
     if ($webmail_enable) {
         $mail->Body = addslashes($body);
         $mail->Subject = addslashes($subject);
     } else {
         $mail->Body = stripslashes($body);
         $mail->Subject = stripslashes($subject);
     }
     if ($pic1 != "none" && $pic1) {
         $mail->AddAttachment("{$pic1}", "{$pic1_name}");
     }
     if ($pic2 != "none" && $pic2) {
         $mail->AddAttachment("{$pic2}", "{$pic2_name}");
     }
Example #7
0
 /**
  * Funcion que envia el correo
  * @param $to
  * @param $cc
  * @param $cco
  * @param $subject
  * @param $from
  * @param $body
  * Valida que los destinatarios con sus
  * respectivos nombres y asunto tengan
  * un formato válido.
  * 	
  * Se envia correo a los destinatarios recibidos 
  * Retorna boolean true al enviar correo exitoso.
  * @return boolean
  */
 public function Send($value = '')
 {
     $to = $this->to;
     // Cuenta que los destinatarios to no sean mas de 5.
     $contador = count($to);
     if ($contador > 5) {
         $this->errors = "MAX_FIVE_RECIPIENTS";
         return 0;
     }
     // Se evoca la funcion validadora para comprobar
     // los formatos de correo y respectivos nombres.
     $t = $this->Valida_dest($to);
     if ($t == 0) {
         return 0;
     }
     $cc = $this->cc;
     // Cuenta que los destinatarios cc(si hubiese) no sean mas de 5.
     $contador = count($cc);
     if ($contador > 5) {
         $this->errors = "MAX_FIVE_COPYS";
         return 0;
     }
     // Se evoca la funcion validadora para comprobar
     // los formatos de correo y respectivos nombres(si hubiese).
     $c = $this->Valida_dest($cc);
     if ($c == 0) {
         return 0;
     }
     $cco = $this->cco;
     // Cuenta que los destinatarios cco(si hubiese) no sean mas de 5.
     $contador = count($cco);
     if ($contador > 20) {
         $this->errors = "MAX_TWENTY_BCC";
         return 0;
     }
     // Se evoca la funcion validadora para comprobar
     // los formatos de correo y respectivos nombres(si hubiese).
     $co = $this->Valida_dest($cco);
     if ($co == 0) {
         return 0;
     }
     $subject = $this->subject;
     // Se evoca la funcion validadora para comprobar
     // el formato del asunto.
     if (!empty($subject)) {
         $s = $this->Valida_headers($subject);
         if ($s == 0) {
             return 0;
         }
         foreach ($subject as $key => $value) {
             $subject = $value;
         }
     }
     $from = $this->from;
     if (!empty($from)) {
         // Se evoca la funcion validadora para comprobar
         // el formato del correo y nombre del remitente.
         $def_from = 1;
         $f = $this->Valida_headers($from);
         if ($f == 0) {
             return 0;
         }
         $from = array();
         foreach ($f as $key => $value) {
             $from[] = $value;
         }
     } else {
         $def_from = 0;
     }
     $replyto = $this->replyto;
     if (!empty($replyto)) {
         $rp = 1;
         // Se evoca la funcion validadora para comprobar
         // el formato del correo y nombre para informar
         // sobre correos fallidos(si hubiese).
         $rt = $this->Valida_headers($replyto);
         if ($rt == 0) {
             return 0;
         }
         $replyto = array();
         foreach ($rt as $key => $value) {
             $replyto[] = $value;
         }
     } else {
         $rp = 0;
     }
     $body = $this->body;
     // Recibimos las rutas y alias de los archivos adjuntos
     // necesarios a enviar en el correo (si hubiese).
     $attachment = $this->attachment;
     if (!empty($attachment)) {
         $z = 2;
         $attachment_r = array();
         $attachment_t = array();
         foreach (new ArrayIterator($this->attachment) as $route => $type) {
             $attachment_r[] = $route;
             $attachment_t[] = $type;
         }
     } else {
         $z = 1;
     }
     // Recibimos las rutas y alias de las imagenes embebidas en un html
     // necesarios a enviar en el correo (si hubiese).
     $embeddedimg = $this->embeddedimg;
     if (!empty($embeddedimg)) {
         $y = 2;
         $embeddedimg_r = array();
         $embeddedimg_t = array();
         foreach (new ArrayIterator($this->embeddedimg) as $route => $type) {
             $embeddedimg_r[] = $route;
             $embeddedimg_t[] = $type;
         }
     } else {
         $y = 1;
     }
     // si se deseára configurar los parametros de el dominio
     // y cuenta de correo default, aquí se recibirian los parámetros.
     $port = $this->port;
     $smtp_secure = $this->smtp_secure;
     $auth = $this->auth;
     $host = $this->host;
     $username = $this->username;
     $password = $this->password;
     $mail = new phpmailer();
     $mail->CharSet = 'UTF-8';
     $mail->Mailer = "smtp";
     $mail->IsSMTP();
     ini_set('max_execution_time', 600);
     $mail->SMTPAuth = true;
     // si se indica un puerto este se utilizara,
     // de lo contrario su usará el default.
     if (empty($port)) {
         $mail->Port = 465;
     } else {
         $mail->Port = $port;
     }
     // si se indica un tipo de seguridad este se utilizara,
     // de lo contrario su usará el default.
     if (empty($smtp_secure)) {
         $mail->SMTPSecure = 'ssl';
     } else {
         $mail->SMTPSecure = $smtp_secure;
     }
     // si se indica un cambio en la autenticación este se utilizara,
     // de lo contrario su usará el default.
     if (empty($auth)) {
         $mail->SMTPAuth = true;
     } else {
         $mail->SMTPAuth = $auth;
     }
     // si se indica un host este se utilizara,
     // de lo contrario su usará el default.
     if (empty($host)) {
         $mail->Host = "securemail.aplus.net";
     } else {
         $mail->Host = $host;
     }
     // si se indica un usuario este se utilizara,
     // de lo contrario su usará el default.
     if (empty($username)) {
         $mail->Username = "******";
     } else {
         $mail->Username = $username;
     }
     // si se indica un password este se utilizara,
     // de lo contrario su usará el default.
     if (empty($password)) {
         $mail->Password = "******";
     } else {
         $mail->Password = $password;
     }
     $mail->Subject = $subject;
     if ($def_from == 1) {
         $mail->SetFrom($from[1], $from[0]);
     } else {
         $mail->SetFrom('*****@*****.**', 'Global Corporation');
     }
     if ($rp == 1) {
         $mail->AddReplyTo($replyto[1], $replyto[0]);
     }
     $mail->Body = " ";
     $mail->MsgHTML($body);
     if ($z == 2) {
         for ($a = 0; $a < count($attachment_r); $a++) {
             $mail->AddAttachment($attachment_r[$a], $attachment_t[$a]);
         }
     }
     if ($y == 2) {
         for ($a = 0; $a < count($embeddedimg_r); $a++) {
             $mail->AddEmbeddedImage($embeddedimg_r[$a], $embeddedimg_t[$a]);
         }
     }
     for ($i = 0; $i < count($to); $i++) {
         $a = $to[$i];
         $mail->AddAddress($a['direccion'], $a['nombre']);
     }
     for ($j = 0; $j < count($cc); $j++) {
         $a = $cc[$j];
         $mail->AddCC($a['direccion'], $a['nombre']);
     }
     for ($k = 0; $k < count($cco); $k++) {
         $a = $cco[$k];
         $mail->AddBCC($a['direccion'], $a['nombre']);
     }
     $mail->IsHTML(true);
     if ($mail->Send()) {
         return true;
     } else {
         $this->errors = "SEND_MAIL_ERROR " . $mail->ErrorInfo;
         return 0;
     }
 }
 /**
  * Set up and send an email
  *
  * The array argument is searched for the following indices:
  *  key           The key of any mail template to be used
  *  section       The module to initialize for (mandatory when key is set)
  *  sender        The sender name
  *  from          The sender e-mail address
  *  to            The recipient e-mail address(es), comma separated
  *  reply         The reply-to e-mail address
  *  cc            The carbon copy e-mail address(es), comma separated
  *  bcc           The blind carbon copy e-mail address(es), comma separated
  *  subject       The message subject
  *  message       The plain text message body
  *  message_html  The HTML message body
  *  html          If this evaluates to true, turns on HTML mode
  *  attachments   An array of file paths to attach.  The array keys may
  *                be used for the paths, and the values for the name.
  *                If the keys are numeric, the values are regarded as paths.
  *  inline        An array of inline (image) file paths to attach.
  *                If this is used, HTML mode is switched on automatically.
  *  search        The array of patterns to be replaced by...
  *  replace       The array of replacements for the patterns
  *  substitution  A more complex structure for replacing placeholders
  *                and/or complete blocks, conditionally or repeatedly.
  * If the key index is present, the corresponding mail template is loaded
  * first.  Other indices present (sender, from, to, subject, message, etc.)
  * will override the template fields.
  * Missing mandatory fields are filled with the
  * default values from the global $_CONFIG array (sender, from, to),
  * or some core language variables (subject, message).
  * A simple {@see str_replace()} is used for the search and replace
  * operation, and the placeholder names are quoted in the substitution,
  * so you cannot use regular expressions.
  * More complex substitutions including repeated blocks may be specified
  * in the substitution subarray of the $arrField parameter value.
  * The e-mail addresses in the To: field will be used as follows:
  * - Groups of addresses are separated by semicola (;)
  * - Single addresses are separated by comma (,)
  * All recipients of any single group are added to the To: field together,
  * Groups are processed separately.  So, if your To: looks like
  *    a@a.com,b@b.com;c@c.com,d@d.com
  * a total of two e-mails will be sent; one to a and b, and a second one
  * to c and d.
  * Addresses for copies (Cc:) and blind copies (Bcc:) are added to all
  * e-mails sent, so if your e-mail is in the Cc: or Bcc: field in the
  * example above, you will receive two copies.
  * Note:  The attachment paths must comply with the requirements for
  * file paths as defined in the {@see File} class version 2.2.0.
  * @static
  * @param   array     $arrField         The array of template fields
  * @return  boolean                     True if the mail could be sent,
  *                                      false otherwise
  * @author  Reto Kohli <*****@*****.**>
  */
 static function send($arrField)
 {
     global $_CONFIG;
     //, $_CORELANG;
     if (!\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         \DBG::log("MailTemplate::send(): ERROR: Failed to load phpMailer");
         return false;
     }
     $objMail = new \phpmailer();
     if (!empty($_CONFIG['coreSmtpServer']) && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         $arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']);
         if ($arrSmtp) {
             $objMail->IsSMTP();
             $objMail->SMTPAuth = true;
             $objMail->Host = $arrSmtp['hostname'];
             $objMail->Port = $arrSmtp['port'];
             $objMail->Username = $arrSmtp['username'];
             $objMail->Password = $arrSmtp['password'];
         }
     }
     if (empty($arrField['lang_id'])) {
         $arrField['lang_id'] = FRONTEND_LANG_ID;
     }
     $section = isset($arrField['section']) ? $arrField['section'] : null;
     $arrTemplate = null;
     if (empty($arrField['key'])) {
         $arrTemplate = self::getEmpty();
     } else {
         $arrTemplate = self::get($section, $arrField['key'], $arrField['lang_id']);
         if (empty($arrTemplate)) {
             \DBG::log("MailTemplate::send(): WARNING: No Template for key {$arrField['key']} (section {$section})");
             return false;
         }
     }
     $search = isset($arrField['search']) && is_array($arrField['search']) ? $arrField['search'] : null;
     $replace = isset($arrField['replace']) && is_array($arrField['replace']) ? $arrField['replace'] : null;
     $substitution = isset($arrField['substitution']) && is_array($arrField['substitution']) ? $arrField['substitution'] : null;
     //echo("Substitution:<br />".nl2br(var_export($arrField['substitution'], true))."<hr />");
     $strip = empty($arrField['do_not_strip_empty_placeholders']);
     // Replace node placeholders generated by Wysiwyg
     $arrTemplate['message_html'] = preg_replace('/\\[\\[NODE_([a-zA-Z_0-9]*)\\]\\]/', '{NODE_$1}', $arrTemplate['message_html']);
     \LinkGenerator::parseTemplate($arrTemplate['message_html'], true);
     foreach ($arrTemplate as $field => &$value) {
         if ($field == 'inline' || $field == 'attachments') {
             continue;
         }
         if (isset($arrField[$field])) {
             $value = $arrField[$field];
         }
         if (empty($value) || is_numeric($value)) {
             continue;
         }
         // TODO: Fix the regex to produce proper "CR/LF" in any case.
         // Must handle any of CR, LF, CR/LF, and LF/CR!
         //                preg_replace('/[\015\012]/', "\015\012", $value);
         if ($search) {
             // we need to replace raw data with HTML entities
             // for HTML-body of email
             if ($field == 'message_html') {
                 foreach ($search as $index => $searchTerm) {
                     $value = str_replace($searchTerm, contrexx_raw2xhtml($replace[$index]), $value);
                 }
             } else {
                 $value = str_replace($search, $replace, $value);
             }
         }
         if ($substitution) {
             $convertToHtmlEntities = false;
             if ($field == 'message_html') {
                 $convertToHtmlEntities = true;
             }
             self::substitute($value, $substitution, $convertToHtmlEntities);
         }
         if ($strip) {
             self::clearEmptyPlaceholders($value);
         }
     }
     //DBG::log("MailTemplate::send(): Substituted: ".var_export($arrTemplate, true));
     //echo("MailTemplate::send(): Substituted:<br /><pre>".nl2br(htmlentities(var_export($arrTemplate, true), ENT_QUOTES, CONTREXX_CHARSET))."</PRE><hr />");
     //die();//return true;
     // Use defaults for missing mandatory fields
     //        if (empty($arrTemplate['sender']))
     //            $arrTemplate['sender'] = $_CONFIG['coreAdminName'];
     if (empty($arrTemplate['from'])) {
         \DBG::log("MailTemplate::send(): INFO: Empty 'from:', falling back to config");
         $arrTemplate['from'] = $_CONFIG['coreAdminEmail'];
     }
     if (empty($arrTemplate['to'])) {
         \DBG::log("MailTemplate::send(): INFO: Empty 'to:', falling back to config");
         $arrTemplate['to'] = $_CONFIG['coreAdminEmail'];
     }
     //        if (empty($arrTemplate['subject']))
     //            $arrTemplate['subject'] = $_CORELANG['TXT_CORE_MAILTEMPLATE_NO_SUBJECT'];
     //        if (empty($arrTemplate['message']))
     //            $arrTemplate['message'] = $_CORELANG['TXT_CORE_MAILTEMPLATE_NO_MESSAGE'];
     $objMail->FromName = $arrTemplate['sender'];
     $objMail->From = $arrTemplate['from'];
     $objMail->Subject = $arrTemplate['subject'];
     $objMail->CharSet = CONTREXX_CHARSET;
     //        $objMail->IsHTML(false);
     if ($arrTemplate['html']) {
         $objMail->IsHTML(true);
         $objMail->Body = $arrTemplate['message_html'];
         $objMail->AltBody = $arrTemplate['message'];
     } else {
         $objMail->Body = $arrTemplate['message'];
     }
     foreach (preg_split('/\\s*,\\s*/', $arrTemplate['reply'], null, PREG_SPLIT_NO_EMPTY) as $address) {
         $objMail->AddReplyTo($address);
     }
     //        foreach (preg_split('/\s*,\s*/', $arrTemplate['to'], null, PREG_SPLIT_NO_EMPTY) as $address) {
     //            $objMail->AddAddress($address);
     //        }
     foreach (preg_split('/\\s*,\\s*/', $arrTemplate['cc'], null, PREG_SPLIT_NO_EMPTY) as $address) {
         $objMail->AddCC($address);
     }
     foreach (preg_split('/\\s*,\\s*/', $arrTemplate['bcc'], null, PREG_SPLIT_NO_EMPTY) as $address) {
         $objMail->AddBCC($address);
     }
     // Applicable to attachments stored with the MailTemplate only!
     $arrTemplate['attachments'] = self::attachmentsToArray($arrTemplate['attachments']);
     //DBG::log("MailTemplate::send(): Template Attachments: ".var_export($arrTemplate['attachments'], true));
     // Now the MailTemplates' attachments index is guaranteed to
     // contain an array.
     // Add attachments from the parameter array, if any.
     if (isset($arrField['attachments']) && is_array($arrField['attachments'])) {
         foreach ($arrField['attachments'] as $path => $name) {
             //                if (empty($path)) $path = $name;
             //                if (empty($name)) $name = basename($path);
             $arrTemplate['attachments'][$path] = $name;
             //DBG::log("MailTemplate::send(): Added Field Attachment: $path / $name");
         }
     }
     //DBG::log("MailTemplate::send(): All Attachments: ".var_export($arrTemplate['attachments'], true));
     foreach ($arrTemplate['attachments'] as $path => $name) {
         if (is_numeric($path)) {
             $path = $name;
         }
         $objMail->AddAttachment(ASCMS_DOCUMENT_ROOT . '/' . $path, $name);
     }
     $arrTemplate['inline'] = self::attachmentsToArray($arrTemplate['inline']);
     if ($arrTemplate['inline']) {
         $arrTemplate['html'] = true;
     }
     foreach ($arrTemplate['inline'] as $path => $name) {
         if (is_numeric($path)) {
             $path = $name;
         }
         $objMail->AddEmbeddedImage(ASCMS_DOCUMENT_ROOT . '/' . $path, uniqid(), $name);
     }
     if (isset($arrField['inline']) && is_array($arrField['inline'])) {
         $arrTemplate['html'] = true;
         foreach ($arrField['inline'] as $path => $name) {
             if (is_numeric($path)) {
                 $path = $name;
             }
             $objMail->AddEmbeddedImage(ASCMS_DOCUMENT_ROOT . '/' . $path, uniqid(), $name);
         }
     }
     //die("MailTemplate::send(): Attachments and inlines<br />".var_export($objMail, true));
     $objMail->CharSet = CONTREXX_CHARSET;
     $objMail->IsHTML($arrTemplate['html']);
     //DBG::log("MailTemplate::send(): Sending: ".nl2br(htmlentities(var_export($objMail, true), ENT_QUOTES, CONTREXX_CHARSET))."<br />Sending...<hr />");
     $result = true;
     foreach (preg_split('/\\s*;\\s*/', $arrTemplate['to'], null, PREG_SPLIT_NO_EMPTY) as $addresses) {
         $objMail->ClearAddresses();
         foreach (preg_split('/\\s*[,]\\s*/', $addresses, null, PREG_SPLIT_NO_EMPTY) as $address) {
             $objMail->AddAddress($address);
         }
         //DBG::log("MailTemplate::send(): ".var_export($objMail, true));
         // TODO: Comment for test only!
         $result &= $objMail->Send();
         // TODO: $objMail->Send() seems to sometimes return true on localhost where
         // sending the mail is actually impossible.  Dunno why.
     }
     return $result;
 }