Last active
September 10, 2019 05:05
-
-
Save pokisin/e9ff84be60806b5db780bf4473ec461f to your computer and use it in GitHub Desktop.
SendMail PHPMailer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_once "phpmailer/class.phpmailer.php"; | |
include_once "phpmailer/class.smtp.php"; | |
public function sendmail($subject,$_mensaje,$to,$sucursal,$ruta){ | |
$mail = new PHPMailer(); | |
$mail->IsSMTP(); | |
$mail->SMTPAuth = true; | |
$mail->SMTPSecure = "tls"; | |
$mail->Host = "smtp.gmail.com"; | |
$mail->Port = 587; | |
$mail->Username = "[email protected]"; // Cuenta de correo | |
$mail->Password = "*********"; //Password cuenta | |
$mail->SMTPDebug = false; | |
$mail->do_debug = 0; | |
// $mail->SMTPDebug = 2; | |
$mail->From = "[email protected]";//de | |
$mail->FromName = "Es un ejemplo de etiqueta";//nombre | |
$mail->Subject = $subject; | |
$mail->AltBody = "Su cliente no soporta html"; | |
//anexo de correos | |
$correos=explode(",",$to); | |
foreach ($correos as $correo) { | |
$mail->AddAddress($correo,"Sistema Excel."); | |
} | |
$mail->AddAttachment($ruta); | |
$mail->Body=$_mensaje; | |
$mail->IsHTML(true); | |
$status = 200; | |
if(!$mail->Send()) {//no envio | |
$respuesta['rs']="error"; | |
$respuesta['desc']="error"; | |
$status = 500; | |
} | |
else {//si envio | |
$respuesta['rs']="OK"; | |
$respuesta['desc']="OK"; | |
$status = 200; | |
} | |
/*---------------------------------------------------------*/ | |
/*---------------------------------------------------------*/ | |
echo "Email enviado correctamente"; | |
}//end sendmailfilesdAction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment