-
Notifications
You must be signed in to change notification settings - Fork 0
/
enviar-prueva.php
49 lines (42 loc) · 1.94 KB
/
enviar-prueva.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
$nombre = $_POST["nombre"];
$correo = $_POST["correo"];
$Telefono = $_POST["Telefono"];
$mensaje = $_POST["mensaje"];
$body = "Nombre: " . $nombre . "<br> Correo: " . $correo . "<br> Telefono: " . $Telefono . "<br> mensaje: " . $mensaje;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
require 'PHPMailer/Exception.php';
require 'PHPMailer/PHPMailer.php';
require 'PHPMailer/SMTP.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'calendasnuyoo@gmail.com'; // SMTP username
$mail->Password = 'monosdecalenda2020'; // SMTP password
$mail->SMTPSecure = 'tls';// Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('calendasnuyoo@gmail.com', $nombre);
$mail->addAddress('calendasnuyoo@gmail.com'); // Add a recipient
$mail->Subject = 'PHPMailer GMail SMTP test';
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'asunto muy importante';
$mail->Body = $body;
$mail->CharSet = 'UTF-8';
$mail->send();
echo '<scrip>
alert("El Mensaje se Envío correctamente");
window.history.go(-1);
</scrip>
';
} catch (Exception $e) {
echo "Hubo un herror al enviar el mensaje : {$mail->ErrorInfo}";
}