-
-
Save ErickCodigo/d1f6e8832c3df26f9b22f5bbb823fd98 to your computer and use it in GitHub Desktop.
PHPMailer Tutorial 2019
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
{ | |
"name": "elporfirio/phpmailer", | |
"description": "Esta es una prueba de envio de email", | |
"authors": [ | |
{ | |
"name": "Porfirio Chavez", | |
"email": "elporfirio@gmail.com" | |
} | |
], | |
"require": { | |
"phpmailer/phpmailer": "^6.0" | |
} | |
} |
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 | |
/** | |
* Created by PhpStorm. | |
* User: elporfirio | |
* Date: 2019-02-26 | |
* Time: 23:13 | |
*/ | |
define('EMAIL_PASSWORD', 'secretpassword'); |
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 | |
/** | |
* Created by PhpStorm. | |
* User: elporfirio | |
* Date: 2019-02-26 | |
* Time: 23:04 | |
*/ | |
use PHPMailer\PHPMailer\PHPMailer; | |
use PHPMailer\PHPMailer\Exception; | |
require 'vendor/autoload.php'; | |
require 'Constantes.php'; | |
$mail = new PHPMailer(true); | |
try { | |
$mail->SMTPDebug = 2; | |
$mail->isSMTP(); | |
$mail->Host = 'smtp.gmail.com'; | |
$mail->SMTPAuth = true; | |
$mail->Username = 'contacto@elporfirio.com'; | |
$mail->Password = EMAIL_PASSWORD; | |
$mail->SMTPSecure = 'tls'; | |
$mail->Port = 587; | |
## MENSAJE A ENVIAR | |
$mail->setFrom('contacto@elporfirio.com'); | |
$mail->addAddress('elporfirio@gmail.com'); | |
$mail->isHTML(true); | |
$mail->Subject = 'Esta es una prueba de email'; | |
$mail->Body = 'Hola mundo desde <b>phpmailer</b>'; | |
$mail->send(); | |
} catch (Exception $exception) { | |
echo 'Algo salio mal', $exception->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment