Query about PHPMAILER and problems with PHP arming

0

$(function(){ $("#btnSubmit").on("click", function(e){

  var errorMessage  = $(".errorMessage");
  var validMessage  = $(".validMessage");

  var hasError = false;
  var hasvalid = true;

  $(".inputValidation").each(function(){
    var $this = $(this);

    if($this.val() == ""){
      hasError = true;
      $this.addClass("inputError");
      errorMessage.html("<p>Por favor, complete los siguientes campos.</p>");
      e.preventDefault();
    }if($this.val() != ""){
      $this.removeClass("inputError"); 

    }else{
      return true; alert(1);
      }

    }); //Input
 

  validMessage.slideDown(700);

  $(".inputValidation").each(function(){
    var $this = $(this);

    if($this.val() == ""){
      hasvalid = false;
      $this.addClass("inputError");
      validMessage.html("<p>Por favor, complete los siguientes campos.</p>");
      e.preventDefault();
    }if($this.val() != ""){
      $this.removeClass("inputError"); 

    }else{
      return true; alert(1);
      }

    }); //Input
  validMessage.slideDown(700);

    /*ajax*/
  if(hasError == false){
      Ecommerce = document.getElementById("exampleInputEcommerce").value;
      Nombre = document.getElementById("exampleInputNombre").value;
      Telefono = document.getElementById("exampleInputPhone").value;
      Email = document.getElementById("exampleInputEmail1").value; 
      data2= { 
          ecommerce:Ecommerce,
          nombre:Nombre,
          telefono:Telefono,
          email:Email,
          tarea: "envio"
        };

      $.ajax({
        type: "POST",
        url:"envio.php",
        data: data2,
        success:function(data){
          console.log("entro");
          /*$('#respuesta').fadeOut('fast').html(
            "Gracias, se a enviado su mensaje"
          );*/

        },
        error: function(XMLHttpRequest, textStatus, errorThrown) { 
          $('.validMessage').fadeOut('fast').html(
            "Gracias, se a enviado su mensaje"
          );
          $(".inputValidation").val("");
        } 

      });

  }




}); //Form .submit
});
.info-section .inputError{
	background-color: #9e46578c!important;
   border-bottom: 2px solid #824747!important;
  color: #fff;
}
.info-section .inputError::-webkit-input-placeholder{
  color: #fff;
}

.info-section .errorMessage{
	/*background-color: #d03e3e; */
    color: #fff;
    clear: right;
    display: none;
    font-size: 14px;
    font-weight: bold;
    height: 55px;
    letter-spacing: 1px;
    -moz-border-radius: 0px 0px 3px 3px;
    -webkit-border-radius: 0px 0px 3px 3px;
    border-radius: 0px 0px 3px 3px;
    margin-top: 21px;
}
.info-section .validMessage{
	/*background-color: #d03e3e; */
    color: #fff;
    clear: right;
    display: none;
    font-size: 14px;
    font-weight: bold;
    height: 55px;
    letter-spacing: 1px;
    -moz-border-radius: 0px 0px 3px 3px;
    -webkit-border-radius: 0px 0px 3px 3px;
    border-radius: 0px 0px 3px 3px;
    margin-top: 21px;
}
.info-section .errorMessage p{
  margin: 0px;
  padding: 19px 0px 0px 30px;
  text-align: left;
}

.info-section .validMessage{
	/*background-color: #d03e3e; */
    color: #fff;
    clear: right;
    display: none;
    font-size: 16px;
    font-weight: bold;
    height: 55px;
    letter-spacing: 1px;
    -moz-border-radius: 0px 0px 3px 3px;
    -webkit-border-radius: 0px 0px 3px 3px;
    border-radius: 0px 0px 3px 3px;
    margin-top: 29px;
  margin: 0px;
  padding: 19px 0px 0px 30px;
  text-align: left;

    display: block!important;
}
.info-section .validMessage p{
  margin: 0px;
  padding: 19px 0px 0px 30px;
  text-align: left;
}
				<form class="formValidation px-lg-2">
				  <div class="form-group">   
				    <input type="name"  class="form-control inputValidation" id="exampleInputEcommerce" aria-describedby="Ecommerce" placeholder="Ecommerce">
				  </div>	
				  <div class="form-group">   
				    <input type="name" class="form-control inputValidation" id="exampleInputNombre" aria-describedby="Nombre" placeholder="Nombre">
				  </div>
				  <div class="form-group">   
				    <input type="phone" class="form-control inputValidation" id="exampleInputPhone" aria-describedby="phone" placeholder="Teléfono">
				  </div> 
				  <div class="form-group mb-5">   
				    <input type="email" class="form-control inputValidation" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Email">
				  </div> 

				  <button type="button" id="btnSubmit" class="btn btn_enviar_form mt-sm-5">ENVIAR</button>

				</form>

				<div class="errorMessage"></div>

				<div class="validMessage" id="respuesta"></div>
     

I am having problems with the form of a Website . It turns out that I'm not sending the data I put to my mailbox, I'm doing the tests in my own mailbox and I'm linking a JS file with a PHP. I read in the documentation of PHPMAILER that I have to link two files plus one class.phpmailer.php and another SMTP.php, I wanted to know if those files have to be configured in any way or linked in any way. With respect to the code I am implementing in the JS where I am doing field validations and including an AJAX and a PHP where I use the following are:

<?php
function envioMail(){

$ecommerce = $_POST["Ecommerce"];
$nombre = $_POST["Nombre"];
$telefono = $_POST["Telefono"];
$email = $_POST["Email"];

require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->Mailer = "smtp";
$mail->SMTPAuth = true;
$mail->Host = "smtp.live.com"; // A RELLENAR. Aquí pondremos el SMTP a utilizar. Por ej. mail.midominio.com smtp.gmail.com
$mail->Username = "[email protected]"; // A RELLENAR. Email de la cuenta de correo. [email protected] La cuenta de correo debe ser creada previamente. 
$mail->Password = ""; // A RELLENAR. Aqui pondremos la contraseña de la cuenta de correo
$mail->From = "[email protected]";  // A RELLENAR Desde donde enviamos (Para mostrar). Puede ser el mismo que el email creado previamente.
$mail->FromName = "Mariano"; //A RELLENAR Nombre a mostrar del remitente. 
$mail->Subject = "Mensaje de Welivery"; // Este es el titulo del email.
$mail->AddAddress("[email protected]");/*email de CM*/

$body  = "Se ha informado la descarga del siguiente resultado: $codigoAlerta Muchas gracias Equipo PfAst Pfizer"; 
$mail->Body = $body;
$mail->CharSet = 'UTF-8';
$mail->Send();

}
if($_POST){
switch($_POST["tarea"]){
case "envio":envioMail();break;
}
}
?>
    
asked by Mariano Andres Franco 16.11.2018 в 00:49
source

1 answer

0

<?php
function envioMail(){

$ecommerce = $_POST["Ecommerce"];
$nombre = $_POST["Nombre"];
$telefono = $_POST["Telefono"];
$email = $_POST["Email"];

require_once(__DIR__.'/PHPMailer/src/Exception.php'); 
require_once(__DIR__.'/PHPMailer/src/PHPMailer.php');
$mail = new PHPMailer(true);

$mail->Mailer = "smtp";
$mail->SMTPAuth = true;
$mail->Host = "smtp.live.com"; // A RELLENAR. Aquí pondremos el SMTP a utilizar. Por ej. mail.midominio.com smtp.gmail.com
$mail->Username = "[email protected]"; // A RELLENAR. Email de la cuenta de correo. [email protected] La cuenta de correo debe ser creada previamente. 
$mail->Password = ""; // A RELLENAR. Aqui pondremos la contraseña de la cuenta de correo
$mail->From = "[email protected]";  // A RELLENAR Desde donde enviamos (Para mostrar). Puede ser el mismo que el email creado previamente.
$mail->FromName = "Mariano"; //A RELLENAR Nombre a mostrar del remitente. 
$mail->Subject = "Mensaje de Welivery"; // Este es el titulo del email.
$mail->AddAddress("[email protected]");/*email de CM*/

$body  = 
"
Se ha informado la descarga del siguiente resultado: $codigoAlerta

Muchas gracias

Equipo PfAst
Pfizer
"; 
$mail->Body = $body;
$mail->CharSet = 'UTF-8';
$mail->Send();

}
if($_POST){
switch($_POST["tarea"]){
case "envio":envioMail();break;
}
}
?>
    
answered by 16.11.2018 в 01:25