timple-c
11/29/2017 - 8:09 PM

phpmailer SMTP timple

phpmailer SMTP timple

<?php 
$body = "";
$to = 'capponi.agostina@gmail.com';

foreach ($_POST as $key => $value) {
	if ( $key != 'invisibleCaptcha' ){
		$body .= "<strong>" . $key . ":</strong> " . $value . "<br>";
	}
}

if($_POST["invisibleCaptcha"] == "human"){
	
	
	require 'PHPMailerAutoload.php';
	
	$mail = new PHPMailer(); 

  $mail->IsSMTP(); 
  $mail->SMTPDebug = 0; //1 muestra errores y mensajes, 2 solo mensajes
  $mail->SMTPAuth = true; 
  $mail->SMTPSecure = 'ssl'; 
  $mail->Host = "smtp.gmail.com";

  $mail->Port = 465; 
  $mail->IsHTML(true);
	$mail->Username = 'webservices@timplemail.com.ar';  
	$mail->Password = '908271ya';  
    
	$mail->setFrom($to, 'NOMBRE DEL REMITENTE');
	$mail->AddAddress($to);
	$mail->Subject = "Consulta desde el formulario de Contacto";

	$mail->msgHTML($body);
	
	$exito = $mail->Send();
	
    if($exito){

        $echoV["result"] = true;
        $echoV["mensaje"] = "Su mensaje ha sido enviado correctamente.";

    } else {

        $echoV["result"] = false;
        $echoV["mensaje"]= "Hubo un error. Intente nuevamente";

    }

} else {

	$echoV["result"] = false;
	$echoV["mensaje"]= "No eres humano o hay un error de configuracion en el formulario";

}

echo json_encode($echoV);