· 8 years ago · Oct 02, 2017, 09:52 PM
1<?php
2include("connection.php");
3
4date_default_timezone_set('Etc/UTC');
5require('PHPMailer/PHPMailerAutoload.php');
6$mail = new PHPMailer;
7$mail->isSMTP();
8$mail->Host = 'smtp.gmail.com';
9$mail->SMTPAuth = true;
10$mail->Username = 'ejemplo@gmail.com';
11$mail->Password = 'aqui tu password';
12$mail->setFrom('ejemplo@gmail.com', 'gmail.com');
13$mail->addAddress('ejemplo@gmail.com', 'Contact Message'); // Add a recipient
14$mail->addAddress('ejemplo@gmail.com', 'Contact Message'); // Add a recipient
15$mail->addReplyTo('ejemplo@gmail.com', 'gmail.com');
16$mail->Subject = 'Contact fron website Hernandez Paiting';
17$mail->IsHTML(true);
18$mail->Subject = 'New Contact Message';
19
20$mail->send();
21$mail->SmtpClose();
22if ( $mail->IsError() ) {
23 echo "Error: <" + $mail->ErrorInfo + " ><br /><br />";
24}
25else {
26 if (headers_sent()){
27 die('<script type="text/javascript">window.location.href="index.php";</script>');
28 }else{
29 header('Location: index.php');
30 die();
31 }
32}
33
34if (isset($_POST["email"]) && !empty($_POST['email'])) {
35 $email = trim($_POST['email']);
36 $code = md5(uniqid(true));
37
38 if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false ) {
39 $checkmail = $connect->query("SELECT email FROM users WHERE email='$email'") or die(mysqli_error('Errorrrrrrr'));
40 $count = mysqli_num_rows($checkmail);
41
42 if ($count==1) {
43 $to = $email;
44 $subject = "Recuperar tu contraseña";
45 $header = "Hernandez Paiting";
46 $body = "Clickea en este link para recuperar tu contraseña: http://localhost/hernandez-painting/back-comentarios/chgpw.php?email=$email&code=$code";
47 mail($to,$subject,$body);
48 }
49 if($checkmail){
50 echo "Se ha enviado un correo a tu email nuevo";
51 }
52 else{
53 echo "Opps, correo no existe";
54 }
55 }
56}
57
58 ?>