function sendMailError($naviera, $mensaje) { //$razonSocial = "MOPSA, S.A. de C.V."; $dominio = "www.almartcon.com"; $att = "Robot"; $mail = new phpmailer(); $mail->Priority = 0; // Se declara la prioridad del mensaje. $mail->PluginDir = "../include/"; $mail->Mailer = "smtp"; $mail->Port = 26; // Configurar la cuenta de correo. $mail->Host = "mail.nesoftware.net"; $mail->SMTPAuth = true; $mail->Username = "******"; $mail->Password = "******"; $mail->From = "*****@*****.**"; $mail->FromName = "Robot ALMARTCON"; //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; // -------------------- // FORMATO HTML // -------------------- $mail->Body = "\n <html>\n <body>\n <font size=\"3\"><b>EDI-CODECO ** E R R O R **</b></font>\n <hr>\n <p>\n A quien corresponda : <br>\n <br>\n El sistema Web ({$dominio}) ha detectado <b><font color=red>{$mensaje}</font></b>.\n \n <br>\n <b>Naviera :</b> {$naviera} <br>\n <br>\n <i>\n Att. {$att} <br>\n </i>\n <p>\n <hr>\n <font color=\"red\" size=\"2\">\n <i>Este es un correo de envio automático generado por nuestro sistema {$dominio}, por favor no responda este email.<br></i>\n </font>\n <br>\n <br>\n <br>\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 =====================================================================\n "; // Nota : // La direccion PARA solo se puede manejar 1. // Las direcciones CC puede manejar N correos. // ------------- // Destinatarios // ------------- $mail->ClearAddresses(); // ------------------------------------------------ // TO : Luis Felipe Pineda Mendoza <*****@*****.**> $mail->AddAddress("*****@*****.**"); $mail->AddCC("*****@*****.**"); $mail->AddCC("*****@*****.**"); $mail->AddCC("*****@*****.**"); // Subject : $mail->Subject = "[EDI-CODECO]{$naviera} :: {$mensaje} "; $exito = $mail->Send(); if (!$exito) { echo "[ <font color=red><b>Problema de envio</b></font> ] " . $mail->ErrorInfo . "<br>"; } else { echo "[ <font color=green><b>OK, E-Mail enviado.</b></font> ] <br>"; } }
function fu_envia_clave($nom, $email, $email_ins, $user, $clave, $tipo) { require_once "class.phpmailer.php"; $mail = new phpmailer(); $mail->From = "*****@*****.**"; $mail->FromName = "Oficina Asesora de Sistemas"; $mail->Host = "mail.udistrital.edu.co"; $mail->Mailer = "smtp"; $mail->SMTPAuth = true; $mail->Username = "******"; $mail->Password = "******"; $mail->Timeout = 120; $mail->Charset = "utf-8"; $mail->IsHTML(false); if ($tipo == 4) { $tip = "Coordinador"; } elseif ($tipo == 16) { $tip = "Decano"; } elseif ($tipo == 24) { $tip = "Funcionario"; } elseif ($tipo == 26) { $tip = "Proveedor"; } elseif ($tipo == 30) { $tip = "Docente"; } elseif ($tipo == 51) { $tip = "Estudiante"; } //echo "tipo en fua_ ".$tipo; exit; $fecha = date("d-M-Y h:i:s A"); $comen = "Mensaje generado automáticamente por el servidor de la Oficina Asesora de Sistemas.\n"; $comen .= "Este es su usuario y clave para ingresar al Sistema de Información Cóndor.\n\n"; $comen .= "Por seguridad cambie la clave.\n\n"; $sujeto = "Clave"; $cuerpo = "Fecha de envio: " . $fecha . "\n\n"; $cuerpo .= "Señor(a) : " . $nom . "\n\n"; $cuerpo .= $comen . "\n\n"; $cuerpo .= "Tipo: " . $tip . "\n"; $cuerpo .= "Usuario: " . $user . "\n"; $cuerpo .= "Clave Acceso: " . $clave . "\n"; $mail->Body = $cuerpo; $mail->Subject = $sujeto; $mail->AddAddress($email); $mail->AddCC($email_ins); if (!$mail->Send()) { header("Location: {$redir}?error_login=16"); } else { header("Location: {$redir}?error_login=18"); } $mail->ClearAllRecipients(); }
$varresult = $db->query("INSERT INTO rhs_gaestebuch (mandant, name, datum, kommentar, email, homepage, icq, aim, yahoo) VALUES('" . $mandant['mandant_id'] . "', '" . $_POST['myname'] . "', '" . $datum . "', '" . $_POST['mymassage'] . "', '" . $_POST['myemail'] . "', '" . $_POST['myhp'] . "', '" . $_POST['myicq'] . "', '" . $_POST['myaim'] . "', '" . $_POST['myyahoo'] . "')"); $_GET['neu'] = 0; $mail = new phpmailer(); $mail->From = $_POST['sender_email']; $mail->FromName = $_POST['sender_email']; $mail->Mailer = "smtp"; $mail->Host = $smtp_mailhost; $mail->SMTPAuth = true; $mail->Username = $smtp_user; $mail->Password = $smtp_pw; $mail->Subject = "EMail vom " . $shopconfig['shopconfig_pagetitle'] . " Gästebuch"; $body = "Hallo " . $_POST['myname'] . ",\nvielen Dank für den Eintrag in unserem Gästebuch,\nName: " . $_POST['myname'] . "\nDatum: " . $datum . "\nEmail: " . $_POST['myemail'] . "\nHomepage: " . $_POST['myhp'] . "\nKommentar: " . $_POST['mymassage'] . "\nText: " . $_POST['text'] . "\n\nDas {$pagename} |" . $mandant['name'] . " Team"; $mail->Body = $body; $mail->AltBody = $body; $mail->AddAddress($_POST['myemail'], $_POST['myname']); $mail->AddCC($mandant['mandant_email'], $mandant['mandant_vorname'] . " " . $mandant['mandant_nachname']); @$mail->Send(); $mail->ClearAddresses(); $mail->ClearAttachments(); } else { print $fehler; if ($fehler == 1) { $smarty->assign("fehler", 1); } if ($fehler == 2) { $smarty->assign("fehler", $fehler); } $_GET['neu'] = 1; $smarty->assign("myname", $_POST['myname']); $smarty->assign("mymassage", $_POST['mymassage']); $smarty->assign("myemail", $_POST['myemail']);
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>"; } }
function sendMail($fileIN, $fileOUT, $naviera) { //$razonSocial = "MOPSA, S.A. de C.V."; $dominio = "www.mopsa-sys.com.mx"; $att = "Robot"; $fileINOnlyName = str_replace("../ediCodeco/", "", $fileIN); $fileOUTOnlyName = str_replace("../ediCodeco/", "", $fileOUT); // ------------------------------------------------ // 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 = new phpmailer(); $mail->Priority = 0; // Se declara la prioridad del mensaje. $mail->PluginDir = "../include/"; $mail->Mailer = "smtp"; $mail->Port = 26; // Configurar la cuenta de correo. $mail->Host = "mail.mopsa-sys.com.mx"; $mail->SMTPAuth = true; $mail->Username = "******"; $mail->Password = "******"; $mail->From = "*****@*****.**"; $mail->FromName = "Robot MOPSA"; //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 = 60; // -------------------- // FORMATO HTML // -------------------- $mail->Body = "\n <html>\n <body>\n <font size=\"3\"><b>EDI-CODECO</b></font>\n <hr>\n <p>\n A quien corresponda : <br>\n <br>\n El sistema Web ({$dominio}) ha detectado en automático nuevas entradas y salidas mismas que fueron codificadas en formato\n EDI-CODECO para reconocimiento informático de otros sistemas navieros.\n <br>\n <b>Naviera :</b> {$naviera} <br>\n <b>Archivo GateIN :</b> {$fileINOnlyName} <br>\n <b>Archivo GateOUT:</b> {$fileOUTOnlyName} <br>\n <br>\n <i>\n Att. {$att} <br>\n </i>\n <p>\n <hr>\n <font color=\"red\" size=\"2\">\n <i>Este es un correo de envio automático generado por nuestro sistema {$dominio}, por favor no responda este email.<br></i>\n </font>\n <br>\n <br>\n <br>\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 =====================================================================\n "; // Nota : // La direccion PARA solo se puede manejar 1. // Las direcciones CC puede manejar N correos. // ------------- // Destinatarios // ------------- $mail->ClearAddresses(); // ------------------------------------------------ // TO : $mail->AddAddress("*****@*****.**"); $mail->AddCC("*****@*****.**"); // BCC : //$mail->AddBCC("*****@*****.**"); // Subject : $mail->Subject = "[EDI-CODECO] {$naviera} "; //Incluir Attach. //$mail->AddAttachment($fileEDI,$fileName); //$mail->AddAttachment($fileEDI,$fileName); $mail->AddAttachment($fileIN, $fileINOnlyName); $mail->AddAttachment($fileOUT, $fileOUTOnlyName); // Se envia el mensaje, si no ha habido problemas, la variable $exito tendra el valor true //if( is_array($arrEdiFile) ){ $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> ] " . $mail->ErrorInfo . "<br>"; } else { echo "[ <font color=green><b>OK, E-Mail enviado.</b></font> ] <br>"; } if (file_exists($fileIN)) { unlink($fileIN); } if (file_exists($fileOUT)) { unlink($fileOUT); } }
function sendMail() { global $hoy; $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 = '******'; $linkPass = '******'; $mail->IsSMTP(); $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; $mail->Host = '10.21.56.22'; // IP 193.138.73.142 $mail->Username = $userName; $mail->Password = $linkPass; $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; // -------------------- // 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></td>\n <td valign=top align=center>\n <font size=\"4\"><b>Mediterranean Shipping Company Mexico 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 - CARGA DE BLS DE MSCLINK A SION</b><BR>{$bl}</font>\n </center>\n <p>\n\n Estimado \n <p>\n El proceso de cargar los Bls de MscLink a SION ha terminado.\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 Mexico (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->Subject = "Finalizo el proceso Cargar-Bls de MscLink a SION"; // 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>"; } }
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>"; } }
} if ($pic3 != "none" && $pic3) { $pic3_file = $tmp_dir . "/pic3.tmp"; 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";
function sendReportEmail($idUsr) { global $hoy; $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 ++ $mail->Host = "10.110.0.12"; $mail->SMTPAuth = true; $mail->Username = "******"; $mail->Password = "******"; $mail->From = "*****@*****.**"; $mail->FromName = "Robot.SION"; //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 = 30; $email = getValueTable("Email", "USUARIO", "Id_usuario", $idUsr); $ejecutivo = getValueTable("Nombre", "USUARIO", "Id_usuario", $idUsr); if (!empty($email)) { // -------------------- // FORMATO HTML // -------------------- $mail->Body = "\n\t\t\t\t<html>\t\t\t\t\t\t\t\t\n\t\t\t\t<body>\t\t\t\t\n\t\t\t\t<b>MEDITERRANEAN SHIPPING COMPANY MEXICO S.A. DE C.V.<BR>\n\t\t\t\tSolo como Agentes / As Agents only</b>\n\t\t\t\t<hr>\t\t\t\t\n\t\t\t\t<b>DEMORAS</b>\n\t\t\t\t<p>\n\t\t\t\t\n\t\t\t\t<center>\t\t\t\t\n\t\t\t\t<b><u>POSIBLES CONTENEDORES EN ABANDONO</u></b>\n\t\t\t\t</center>\n\t\t\t\t<p>\t\t\t\t\t\t\t\t\n\t\t\t\t<b>{$ejecutivo} :</b>\n\t\t\t\t<p>\t\t\t\t\n\t\t\t\tEl sistema ha detectado algunos clientes que tienen contenedores con mas de 15 días incurriendo en demoras,\n\t\t\t\tfavor de revisar a la brevedad. Adjunto archivo.\n\t\t\t\t<p>\t\t\t\n\t\t\t\tNOTA : El archivo tiene formato CSV, pero se puede abrir con MS-Excel sin problema.\n\t\t\t\t<p>\n\t\t\t\tAtt. Robot SION.\n\t\t\t\t<p>\t\t\t\t\n\t\t\t\t<hr>\n\t\t\t\t<font color=red><b>\n\t\t\t\t* FAVOR DE NO RESPONDER A ESTA DIRECCIÓN DE CORREO YA QUE NO SE RECIBIRA SU MENSAJE Y POR CONSIGUIENTE NO SERA ATENDIDO.\n\t\t\t\t</b>\n\t\t\t\t</font>\t\t\t\t\n\t\t\t\t<p>\t\t\t\t\t\t\t\t\n\t\t\t"; // ------------------------------------------------------- // FORMATO TEXTO // Definimos AltBody por si el destinatario del correo // no admite email con formato html // ------------------------------------------------------- $mail->AltBody = "\nMEDITERRANEAN SHIPPING COMPANY MÉXICO\nMSC México (As Agents Only-Solo como Agentes)\n=====================================================================\n\nYour are a Winner !!!\n\n{$ejecutivo} :\n\nEl sistema ha detectado algunos clientes que tienen contenedores con mas de 15 días incurriendo en demoras,\nfavor de revisar a la brevedad. Adjunto archivo.\nHasta luego.\nAtt. Robot SION.\n* FAVOR DE NO RESPONDER A ESTA DIRECCIÓN DE CORREO YA QUE NO SE RECIBIRA SU MENSAJE Y POR CONSIGUIENTE NO SERA ATENDIDO.\n"; // Nota : // La direccion PARA solo se puede manejar 1. // Las direcciones CC puede manejar N correos. // ------------- // Destinatarios // ------------- $mail->ClearAddresses(); // ------------------------------------------------ $mail->AddAddress("{$email}"); $mail->AddCC("*****@*****.**"); $mail->AddCC("*****@*****.**"); $mail->Subject = "[SION] Pos.Abandono / {$ejecutivo} "; // Incluir Attach. $mail->AddAttachment("../files/demPosAba_{$idUsr}.zip", "demPosAba_{$idUsr}.zip"); // Se envia el mensaje, si no ha habido problemas, la variable $exito tendra el valor true $exito = $mail->Send(); //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> ] <b><a href=\"javascript:ventanaNueva('csNfyCatCli2.php?modo=consulta&idCliente={$idCli}',600,400)\">{$cliente}</a></b> -> <i>{$emailDestino}</i> -> {$valor}" . $mail->ErrorInfo . "<br>"; } else { // echo "[ <font color=green><b>Enviado</b></font> ] <b><a href=\"javascript:ventanaNueva('csNfyCatCli2.php?modo=consulta&idCliente=$idCli',600,400)\">$cliente</a></b> -> <i>$emailDestino</i> <br>"; } } }
/** * 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; }