-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendMail.php
More file actions
189 lines (133 loc) · 6.4 KB
/
sendMail.php
File metadata and controls
189 lines (133 loc) · 6.4 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
<?php //_________________________________________GL_HF____________________________________________
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load composer's autoloader
require 'vendor/autoload.php';
include_once 'dbh.inc.php';
/*This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.*/
$feedback_page = "index.php";
// $error_page = "error_message.html";
// $thankyou_page = "profesionales/index.php";
// ddbb: multiviahr_suscriptions
// user: multiviahr_admin
// pass: ERh[lZeL6UGR
/*This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.*/
// $a1 = $_POST['a1'];
// $a2 = $_POST['a2'];
// $a3 = $_POST['a3'];
// $a4 = $_POST['a4'];
// $a5 = $_POST['a5'];
// $a6 = $_POST['a6'];
$fst = $_POST['a1'];
$lst = $_POST['a2'];
$cny = $_POST['a3'];
$eml = $_POST['a4'];
$phn = $_POST['a5'];
$rch = $_POST['recaptcha'];
// $tyc = $_POST['a6'];
if($_POST['a6']=='on'){$tyc=1;}else{$tyc=0;}
$timestamp = date("Y-m-d H:i:s");
if($_POST['a9'] != ""){
header( "Location: https://multiviahr.info/?mail=nope" . $_POST['a9'] );
exit;
} else {
$site = '6LdrMsgUAAAAALibglcP8-LSLA7YMkVUorWUnq4l';
$scrt = '6LdrMsgUAAAAANLWAiRMTvl5p9CcpNyMV2d6712O';
if (isset($_POST['submit'])) {
$response = $_POST['g-recaptcha-response'];
$payload = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$scrt.'&response='.$response);
// echo $payload;
$result = json_decode($payload,true);
if ($result['success']!=1) {
// code...
header( "Location: https://multiviahr.info/?mail=BOT" );
// echo 'you are evil or a bott';
exit;
// return false;
} else {
// Error handlers
// Check if imput characters are valid
if (preg_match("/[\']/",$uid)||preg_match("/[\']/",$fst)||preg_match("/[\']/",$lst)||preg_match("/[\']/",$eml)||preg_match("/[\']/",$pwd)) {
echo"if";exit(); // if = invalid fields
// }else{$qry="SELECT * FROM users WHERE eml = '$eml';";$ress=$conn->query($qry);$resp=$ress->fetch_all(MYSQLI_ASSOC);
// if($resp){echo"mt";exit(); // mt = mail taken
}else{ // Insert the user into the database
try{
$qry=$conn2->prepare("INSERT INTO suscriptions (fst,lst,cny,eml,phn,tyc) VALUES ('$fst','$lst','$cny','$eml','$phn','$tyc');");
$qry->execute();
// echo"ok";
}catch(PDOException $e){echo 'Error: '.$e->getMessage()." file: ".$e->getFile()." line: ".$e->getLine();exit;}
// exit();
}
//______________________________Datos guardados en variables____________________________________
//___________________________ENVIO el mail a quien corresponda__________________________________
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 4; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
// $mail->Host = 'smtp.lattedev.com'; // Specify main and backup SMTP servers
$mail->Host = gethostbyname('webmail.multiviahr.info'); // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
// $mail->Username = 'idemo@idemomotors.com'; // SMTP username
// $mail->Password = 'Idemomotors25'; // SMTP password
$mail->Username = 'formulario@multiviahr.info'; // SMTP username
$mail->Password = '1nTr-Fl3x20'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ));
//Recipients
$mail->setFrom('test@multiviahr.info', 'Consultas Interflex');
// $mail->addAddress('molinerozadkiel@gmail.com', 'Markus'); // Add a recipient
$mail->addAddress('asist.tecnica@interflex.es', 'Interflex'); // Add a recipient
// $mail->addAddress($email_address, $first_name); // Add a recipient
// $mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('webdesign@mediactiu.com', 'Consultas Interflex');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
//Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Nueva consulta de '.$a1;
$mail->Body =
'nombre: '.$fst.'<br>'.
'apellido: '.$lst.'<br>'.
'empresa: '.$cny.'<br>'.
'e-mail: '.$eml.'<br>'.
'telefono: '.$phn.'<br>'.
'terms and conditions: '.$tyc.'<br>'.
'fecha y hora: '.$timestamp;
$mail->AltBody =
'nombre: '.$fst.'<br>'.
'apellido: '.$lst.'<br>'.
'empresa: '.$cny.'<br>'.
'e-mail: '.$eml.'<br>'.
'telefono: '.$phn.'<br>'.
'terms and conditions: '.$tyc.'<br>'.
'fecha y hora: '.$timestamp;
// header( "Location: $thankyou_page" );
// header( "Location: index.php?mail=success" );
// var_dump($mail)
header( "Location: https://multiviahr.info/?mail=success" );
$mail->send();
exit;
} catch (Exception $e) {
header( "Location: https://multiviahr.info/?mail=error" );
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
// header( "Location: index.php?mail=error" );
exit;
}
}
// header( "Location: https://multiviahr.info/?mail=HUMAN" );
// echo 'thank you';
// exit;
}
}
//______________________________________$mail ENVIADO_________________________________________
//__________________________________________GG_WP_____________________________________________?>