I am wanting to associate a gmail account with Php mailer but I am not having an answer when it comes to receiving data from a form. The page I'm doing is the following and the file I'm doing is the one I attached below. What I do not know if there is something to take into account to generate PHP with gmail.
<?php
//error_reporting(E_ALL);
error_reporting(E_STRICT);
date_default_timezone_set('America/Argentina/Buenos_Aires');
if ((isset($_POST['ecommerce']) && $_POST['ecommerce'] != "") &&
(isset($_POST['nombre']) && $_POST['nombre'] != "") &&
(isset($_POST['telefono']) && $_POST['telefono']!= "" ) &&
(isset($_POST['email']) && $_POST['email']!= "") &&
(isset($_POST['envio']) && $_POST['envio'] === 'envio') ){
require_once('mailer/class.phpmailer.php');
$emailCliente = "[email protected]";
$passwordCliente = "xxx17";
$fromCliente = $emailCliente;
$ecommerce = $_POST["ecommerce"];
$nombre = $_POST["nombre"];
$telefono = $_POST["telefono"];
$email = $_POST["email"];
$envio = $_POST['envio'];
$address = $email;
$body =
"
Datos enviados por el usuario desde el Formulario de contacto: <br/>
<strong>Ecommerce:</strong> $ecommerce <br/>
<strong>Nombre y Apellido:</strong> $nombre <br/>
<strong>Teléfono:</strong> $telefono <br/>
<strong>Email:</strong> $email <br/>
";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "smtp.gmail.com"; // saber que tipo de cuenta.
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->SMTPAuth= true;
$mail->Port = 465;
$mail->Username= $emailCliente; // su cuenta de correo
$mail->Password= $passwordCliente; // su contraseña
$mail->From = $emailCliente; // su cuenta
$mail->FromName= "Welivery";
$mail->isHTML(true);
$mail->Subject ="Mensaje de Welivery";
$mail->Body = $body;
$mail->addAddress($address, $nombre);
if (!$mail->send()) {
$output = json_encode(array('type' => 'error', 'text' => 'Error - Comuniquese con el Administrador de la pagina '));
die($output);
} else {
$output = json_encode(array('type' => 'message', 'text' => 'Tu mensaje se ha enviado correctamente. A la brevedad nos contactaremos. Muchas gracias'));
die($output);
}
} else {
$output = json_encode(array('type' => 'message', 'text' =>'No se pudo enviar el email, asegurese que el email exista!!!'));
die($output);
}