-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.php
More file actions
228 lines (197 loc) · 7.81 KB
/
mail.php
File metadata and controls
228 lines (197 loc) · 7.81 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
if(!isset($_SESSION['datos_login'])){
}
$arregloUsuario = $_SESSION['datos_login'];
if(isset($_SESSION['carrito'])){
if(isset($_GET['id'])){
$arreglo =$_SESSION['carrito'];
$encontro=false;
$numero = 0;
for($i=0;$i<count($arreglo);$i++){
if($arreglo[$i]['Id'] == $_GET['id']){
$encontro=true;
$numero=$i;
}
}
if($encontro == true){
$arreglo[$numero]['Cantidad']=$arreglo[$numero]['Cantidad']+1;
$_SESSION['carrito']=$arreglo;
header("Location: ./cart.php");
}else{
$nombre = "";
$precio= "";
$imagen= "";
$res= $conexion->query('select * from productos where id='.$_GET['id'])or die($conexion->error);
$fila = mysqli_fetch_row($res);
$nombre=$fila['1'];
$precio = $fila[3];
$imagen = $fila[4];
$arregloNuevo = array(
'Id'=> $_GET['id'],
'Nombre'=> $nombre,
'Precio'=>$precio,
'Imagen'=> $imagen,
'Cantidad' => 1
);
array_push($arreglo, $arregloNuevo);
$_SESSION['carrito']=$arreglo;
header("Location: ./cart.php");
}
}
}else{
if(isset($_GET['id'])){
$nombre = "";
$precio= "";
$imagen= "";
$res= $conexion->query('select * from productos where id='.$_GET['id'])or die($conexion->error);
$fila = mysqli_fetch_row($res);
$nombre=$fila['1'];
$precio = $fila[3];
$imagen = $fila[4];
$arreglo[] = array(
'Id'=> $_GET['id'],
'Nombre'=> $nombre,
'Precio'=>$precio,
'Imagen'=> $imagen,
'Cantidad' => 1
);
$_SESSION['carrito']=$arreglo;
header("Location: ./cart.php");
}
}
if( isset($_POST['email']) && isset($_POST['password']) ){
}
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PhpMailer/Exception.php';
require 'PhpMailer/PHPMailer.php';
require 'PhpMailer/SMTP.php';
$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 = 'ratafak15@gmail.com'; //SMTP username
$mail->Password = 'Sorayasuazo_157979'; //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('ratafak15@gmail.com', 'MynorParrales');
$mail->addAddress('ratafak15@gmail.com', 'Joe User'); //Add a recipient
$mail->addAddress('jasson171100@gmail.com');
$mail->addAddress('torresivan841@gmail.com');
$mail->addAddress('leonelmartineznic@gmail.com');
//Attachments
//Optional name
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Gracias por tu compra';
$mail->Body = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Factura</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<img class="anulada" src="img/anulado.png" alt="Anulada">
<div id="page_pdf">
<table id="factura_head">
<tr>
<td class="logo_factura">
<div>
<img src="../images/MOGJI.ico">
</div>
</td>
<td class="info_empresa">
<div>
<span class="h2">MOGJI STORE</span>
<p>Luis alfonso</p>
<p>Teléfono: +(505) 86625526</p>
<p>Email: '.$arregloUsuario['email'].'</p>
</div>
</td>
<td class="info_factura">
<div class="round">
<span class="h3">Factura</span>
<p>No. Factura: <strong>7698768</strong></p>
<p>Fecha: 8/6/2021</p>
<p>Hora: 10:30am</p>
<p>Vendedor: Jorge Pérez Hernández Cabrera</p>
</div>
</td>
</tr>
</table>
<table id="factura_cliente">
<tr>
<td class="info_cliente">
<div class="round">
<span class="h3">Cliente</span>
<table class="datos_cliente">
<tr>
<td><label>Nit:</label><p>'.$arregloUsuario['id_usuario'].'</p></td>
<td><label>Teléfono:</label> <p>7854526</p></td>
</tr>
<tr>
<td><label>Nombre:'.$arregloUsuario['nombre'].'</label> <p></p></td>
<td><label>Dirección:</label> <p></p></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table id="factura_detalle">
<thead>
<tr>
<th width="50px">Cant.</th>
<th class="textleft">Descripción</th>
<th class="textright" width="150px">.</th>
<th class="textright" width="150px"> Precio Total</th>
</tr>
</thead>
<tbody id="detalle_productos">
<tr>
<td class="textcenter">1</td>
<td></td>
<td class="textright">516.67</td>
<td class="textright">516.67</td>
</tr>
<tr>
<td class="textcenter">2</td>
<td></td>
<td class="textright"></td>
<td class="textright"></td>
</tr>
</tbody>
<tfoot id="detalle_totales">
<tr>
<td colspan="3" class="textright"><span>SUBTOTAL</span></td>
<td class="textright"><span></span></td>
</tr>
<tr>
<td colspan="3" class="textright"><span>IVA</span></td>
<td class="textright"><span>516.67</span></td>
</tr>
<tr>
<td colspan="3" class="textright"><span>TOTAL</span></td>
<td class="textright"><span></span></td>
</tr>
</tfoot>
</table>
<div>
<p class="nota">Si usted tiene preguntas sobre esta factura, <br>pongase en contacto con nombre, teléfono y Email</p>
<h4 class="label_gracias">¡Gracias por su compra!</h4>
</div>
</div>
</body>
</html>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'correo enviado';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>