Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("connection.php");
- date_default_timezone_set('Etc/UTC');
- require('PHPMailer/PHPMailerAutoload.php');
- $mail = new PHPMailer;
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'ejemplo@gmail.com';
- $mail->Password = 'aqui tu password';
- $mail->setFrom('ejemplo@gmail.com', 'gmail.com');
- $mail->addAddress('ejemplo@gmail.com', 'Contact Message'); // Add a recipient
- $mail->addAddress('ejemplo@gmail.com', 'Contact Message'); // Add a recipient
- $mail->addReplyTo('ejemplo@gmail.com', 'gmail.com');
- $mail->Subject = 'Contact fron website Hernandez Paiting';
- $mail->IsHTML(true);
- $mail->Subject = 'New Contact Message';
- $mail->send();
- $mail->SmtpClose();
- if ( $mail->IsError() ) {
- echo "Error: <" + $mail->ErrorInfo + " ><br /><br />";
- }
- else {
- if (headers_sent()){
- die('<script type="text/javascript">window.location.href="index.php";</script>');
- }else{
- header('Location: index.php');
- die();
- }
- }
- if (isset($_POST["email"]) && !empty($_POST['email'])) {
- $email = trim($_POST['email']);
- $code = md5(uniqid(true));
- if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false ) {
- $checkmail = $connect->query("SELECT email FROM users WHERE email='$email'") or die(mysqli_error('Errorrrrrrr'));
- $count = mysqli_num_rows($checkmail);
- if ($count==1) {
- $to = $email;
- $subject = "Recuperar tu contraseña";
- $header = "Hernandez Paiting";
- $body = "Clickea en este link para recuperar tu contraseña: http://localhost/hernandez-painting/back-comentarios/chgpw.php?email=$email&code=$code";
- mail($to,$subject,$body);
- }
- if($checkmail){
- echo "Se ha enviado un correo a tu email nuevo";
- }
- else{
- echo "Opps, correo no existe";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement