Created
July 22, 2019 21:33
-
-
Save CristalT/a750e630801ffffba8a703aa11435ccb to your computer and use it in GitHub Desktop.
Ejemplo de envío de mail para aplicaciones alojadas en donweb.
This file contains hidden or 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
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', 1); | |
require 'vendor/phpmailer/phpmailer/src/Exception.php'; | |
require 'vendor/phpmailer/phpmailer/src/PHPMailer.php'; | |
require 'vendor/phpmailer/phpmailer/src/SMTP.php'; | |
use PHPMailer\PHPMailer\PHPMailer; | |
use PHPMailer\PHPMailer\Exception; | |
$mail = new PHPMailer(); | |
try { | |
$mail->isSMTP(); | |
$mail->Host = 'mail.xxxx.com.ar'; | |
$mail->SMTPAuth = true; | |
$mail->Username = '[email protected]'; | |
$mail->Password = 'Xxxxx'; | |
$mail->Port = 587; | |
$mail->CharSet = 'utf-8'; | |
$mail->SMTPOptions = array( | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false, | |
'allow_self_signed' => true | |
) | |
); | |
$mail->setFrom('[email protected]', 'XXXX'); | |
$mail->addAddress('[email protected]', 'XXXX XXXX'); | |
$mail->isHTML(true); | |
$mail->Subject = 'Recuperación de contraseña'; | |
$mail->Body = "Su nueva clave de acceso es XXX"; | |
$mail->send(); | |
} catch (Exception $e) { | |
return "El mensaje no pudo ser enviado. Error: $mail->ErrorInfo"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey lo acabo de usar y me súpero sirvió lo de SMTPOptions, mil gracias!