Last active
May 24, 2021 16:26
-
-
Save joseluisq/709543d65cbfc117168d760e5223f76a to your computer and use it in GitHub Desktop.
PHPMailer: Ejemplo de envío de email simple.
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 | |
/** | |
* PHPMailer: Ejemplo de envío de email simple. | |
*/ | |
require __DIR__ . '/class.phpmailer.php'; | |
// Crear una instancia de la clase PHPMailer | |
$mail = new PHPMailer; | |
// Envio de email simple | |
$mail->isMail(); | |
// Desplegar errores y activar el debug | |
$mail->SMTPDebug = 4; | |
// Email del remitente (puedes poner algun email de prueba) | |
$mail->setFrom('from@example.com', 'Nombre Apellido'); | |
// Email del destinatario (a quíen se enviará el mensaje) | |
$mail->addAddress('whoto@example.com', 'Nombre Apellido'); | |
// Aquí agregar el asunto del mensaje | |
$mail->Subject = 'ASUNTO DEL MENSAJE'; | |
// Escribir el mensaje HTML | |
$message = '<h1>MENSAJE HTML</h1>'; | |
$mail->msgHTML($message); | |
// Enviar el mensaje y verificar si existen errores | |
if ($mail->send()) { | |
echo "MENSAJE SE HA ENVIADO"; | |
} else { | |
echo "ERROR AL ENVIAR MENSAJE"; | |
} |
buenas tarder, gracias por sus aportes, me pregunto si me pueden apoyar, he utilizado las clase como lo indican y me sale siempre error en linea 19,
Call to undefined method PHPMailer::setFrom() in C:\wamp\www\php_mailer_2_lib\envio_simple.php on line 19
Buenas! Quisiera saber si me pueden ayudar respecto a añadir un temporizador para el mensaje, hice el procedimiento y funciona, pero no se como hacer que luego de un determinado tiempo se elimine el mensaje. Gracias
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cuando se envia el mensaje el destinatario le aparece como remitente el root del servidor donde esta hospedada la aplicación, alguna sugerencia?
se realizo edicion de setFrom, de igual forma aparece xxxxxx@server32.rootservers.co