$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
if (!$name AND !$email AND !$message){
header("Location: contacto.php?msg=off");
return false;
}else{
/*Enviamos el mail*/
include('lib/template.php');
include "class.phpmailer.php";
include "class.smtp.php";
$email_user = 'tu correo';
$email_password = 'tu contraseña';
$the_subject = "Mensaje recibido de tu web";
$address_to = 'correo para quien va';
$from_name = 'Cursos de programación';
$phpmailer = new PHPMailer();
$phpmailer->Username = $email_user;
$phpmailer->Password = $email_password;
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->Host = 'SERVIDOR';
$phpmailer->Port = 465;
$phpmailer->isSMTP();
$phpmailer->SMTPAuth = true;
$phpmailer->setFrom($phpmailer->Username,$from_name);
$phpmailer->AddAddress($address_to);
$phpmailer->FromName = 'Programación Online';
$phpmailer->Subject = $the_subject;
$phpmailer->Body .= $mensaje_correo;
$phpmailer->IsHTML(true);
if (!$phpmailer->Send()) {
header("Location: contacto.php?msg=off");
}else{
header("Location: contacto.php?msg=ok");
}
}
|