Created
December 30, 2021 06:20
-
-
Save RocketFever22/309f1dd1d300063de9afd82f6e5e4c1a to your computer and use it in GitHub Desktop.
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
<?php | |
use PHPMailer\PHPMailer\PHPMailer; | |
use PHPMailer\PHPMailer\Exception; | |
require '../extras/PHPMailer/src/Exception.php'; | |
require '../extras/PHPMailer/src/PHPMailer.php'; | |
require '../extras/PHPMailer/src/SMTP.php'; | |
$mail = new PHPMailer; | |
$mail->isSMTP(); | |
$mail->SMTPDebug = 2; // 0 = off (for production use) - 1 = client messages - 2 = client and server messages | |
$mail->SMTPSecure = 'tls'; // ssl is depracated | |
$mail->SMTPAuth = true; | |
/* | |
Esto es lo que se suele cambiar | |
*/ | |
$mail->Host = "smtp.gmail.com"; // use $mail->Host = gethostbyname('smtp.gmail.com'); // if your network does not support SMTP over IPv6 | |
$mail->Port = 587; // TLS only | |
$mail->Username = ""; | |
$mail->Password = ""; | |
$mail->setFrom("email@remitente.com"); | |
$mail->addAddress('email@destino.com'); | |
$mail->Subject = 'PHPMailer GMail SMTP test'; | |
$mail->msgHTML("test body"); //$mail->msgHTML(file_get_contents('contents.html'), __DIR__); //Read an HTML message body from an external file, convert referenced images to embedded, | |
$mail->AltBody = 'HTML messaging not supported'; | |
// $mail->addAttachment('images/phpmailer_mini.png'); //Attach an image file | |
if(!$mail->send()){ | |
echo "Mailer Error: " . $mail->ErrorInfo; | |
}else{ | |
echo "Message sent!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment