-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenviocontacto.php
76 lines (61 loc) · 2.26 KB
/
enviocontacto.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* envia correo con los datos del formulario contacto
*/
require 'lib/PHPMailer/PHPMailerAutoload.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$nombre = $_POST['nombre'];
$nombre = $_POST['apellido'];
$asunto = $_POST['asunto'];
$email = $_POST['email'];
$telefono = $_POST['tlf'];
$comentario = $_POST['comentarios'];
//$token = sha1(uniqid());
//Create a new PHPMailer instance
$mail = new PHPMailer;
// Set PHPMailer to use the sendmail transport
// $mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom($email, $nombre);
//Set an alternative reply-to address
//$mail->addReplyTo('[email protected]', 'Limchile');
//Set who the message is to be sent to
// $mail->addAddress('[email protected]', 'Boxapp');
$mail->addAddress('[email protected]', 'Boxapp');
//set CC
$mail->AddCC($email, $nombre);
//adding file from the form
if (isset($_FILES['userfile']) && $_FILES['userfile']['error'] == UPLOAD_ERR_OK) {
$mail->AddAttachment($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name']);
}
// Set email format to HTML
$mail->isHTML(true);
$mail->Subject = $nombre.' - Contacto Boxapp.cl';
$mail->Body = '
<div>
<img src="https://www.boxapp.cl/boxappweb/public/images/boxapplogo.png" width="17%" height="auto" />
</div>
<div style="position:relative;width:100%;">
<div style="width:70%;background:#fff;margin:3% auto;padding:1%;position:absolute;top:-40%;left:60%;transform:translateX(-50%);">
<h2>Formulario Contacto - Boxapp</h2>
<p style="max-width:200px">
Enviado por: '.$nombre.'<br>
Asunto: '.$asunto.'<br>
Teléfono: '.$telefono.'<br><br>
Comentarios Adicionales: '.$comentario.'<br>
</p>
<div style="width:100%;margin-top:40px;font-size:0.8em;color:#ccc;">
</div>
</div>
</div>
';
$mail->AltBody = '<h2>Formulario Contacto - Boxapp</h2>';
$r = array();
if(!$mail->send()) {
$r = array('ok' => false);
} else {
$r = array('ok' => true);
};
header('Content-Type: application/json;charset=utf-8');
echo json_encode($r, true);
}