Skip to content

Instantly share code, notes, and snippets.

@ErickCodigo
Forked from porfidev/Constantes.php
Created October 7, 2019 16:14
Show Gist options
  • Save ErickCodigo/d1f6e8832c3df26f9b22f5bbb823fd98 to your computer and use it in GitHub Desktop.
Save ErickCodigo/d1f6e8832c3df26f9b22f5bbb823fd98 to your computer and use it in GitHub Desktop.
PHPMailer Tutorial 2019
{
"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"
}
}
<?php
/**
* Created by PhpStorm.
* User: elporfirio
* Date: 2019-02-26
* Time: 23:13
*/
define('EMAIL_PASSWORD', 'secretpassword');
<?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