-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorreo.php
More file actions
33 lines (30 loc) · 1.1 KB
/
correo.php
File metadata and controls
33 lines (30 loc) · 1.1 KB
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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
$result = "";
if(isset($_POST['enviar'])){
$result = $_POST['nombre'];
require 'PHPMailer/PHPMailer.php';
require 'PHPMailer/Exception.php';
require 'PHPMailer/SMTP.php';
$mail = new PHPMailer;
$mail -> isSMTP();
$mail -> Host ='smtp.gmail.com';
$mail -> Port = 587;
$mail ->SMTPAuth = true;
$mail ->SMTPSecure = 'tls';
$mail ->Username = 'generalmantencion2022@gmail.com';
$mail ->Password = 'kyzevslkykdefkpb';
$mail -> setFrom($_POST['email'], $_POST['nombre']);
$mail -> addAddress('generalmantencion2022@gmail.com');
$mail -> addReplyTo($_POST['email'],$_POST['nombre']);
$mail -> isHTML(true);
$mail -> Subject='Correo enviado desde pagina web';
$mail -> Body = '<h3 align=center>Correo: '.$_POST['email'].'<br>Nombre: '.$_POST['nombre'].'<br>Telefono: '.$_POST['telefono'].'<br>Mensaje: '.$_POST['mensaje'].'</h3>';
if(!$mail -> send()){
$result = "Algo ocurrio mal, intentalo denuevo mas tarde";
} else{
$result = "Correo enviado con exito";
}
}
?>