-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathformCorreoController.php
More file actions
55 lines (41 loc) · 1.35 KB
/
formCorreoController.php
File metadata and controls
55 lines (41 loc) · 1.35 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once dirname(__FILE__)."/include/smarty.php";
require_once dirname(__FILE__) ."/include/database.php";
$title="Correo nuevo";
$oSmarty->assign("t","$title");
$oSmarty -> assign("contenido", "formPHPMailer.html.tpl");
$oSmarty -> display("layout.html.tpl");
if(isset($_POST['envia_correo'])){
require_once dirname(__FILE__)."/libs/phpmailer/class.phpmailer.php";
require_once dirname(__FILE__)."/libs/phpmailer/class.smtp.php";
$para = $_POST['email'];
$asunto = $_POST['asunto'];
$mensaje = $_POST['mensaje'];
$name = $_FILES['archivo']['name'];
$tmp_name = $_FILES['archivo']['tmp_name'];
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host ="smtp.gmail.com";
$mail->Port = 465;
$mail->Username = 'miemail@mail.com';
$mail->Password = 'mipassword';
//datos personales quien es el que lo envia
$mail->From = "emailremitente@mail.com";
$mail->FromName = 'Tienda 24';
//para quien es el email
$mail->Subject = $asunto;
$mail->AddAddress($para);
//cuerpo del mensaje
$mail->Body = $mensaje;
$mail -> AddAttachment ($tmp_name, $name);
$r=$mail->Send();
if($r)
{
print "<script language='JavaScript'>alert('Mensaje enviado correctamente');</script>";
}else
print "<script language='JavaScript'>alert('No se pudo enviar el mensaje $mail->ErrorInfo');</script> ";
}
?>