<?php
/* Parametros para varios servidores
HOTMAIL
$smtp->SMTPAuth = true;
$smtp->SMTPSecure = "tls";
$smtp->Host = "smtp.live.com";
$smtp->Username = "miCuenta@outlook.com";
$smtp->Password = "miPassword";
$smtp->Port = 25;
GMAIL
$smtp->SMTPAuth = true;
$smtp->SMTPSecure = "tls";
$smtp->Host = "smtp.gmail.com";
$smtp->Username = "miCuenta@gmail.com";
$smtp->Password = "miPassword";
$smtp->Port = 587;
YAHOO
$smtp->SMTPAuth = true;
$smtp->SMTPSecure = "ssl";
$smtp->Host = "smtp.mail.yahoo.com";
$smtp->Username = "miCuenta@yahoo.com";
$smtp->Password = "miPassword";
$smtp->Port = 465;
*/
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer;
// $mail->SMTPDebug = 3; // Enable verbose debug output
$enviar2 = '';
// Configurar el servidor, cambiar solo email y paasword si es de yahoo.
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mail.yahoo.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xxxxxxxxxx@yahoo.es'; // SMTP username
$mail->Password = 'xxxxxxxxx'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
// Parametros para configurar
$correo = 'xxxxxxxxxxxxx@yahoo.es';
$mailer = 'Mi web';
$enviar1 = 'xxxxxxxxxxxxx@yahoo.es'; // Obligatorio
$enviar2 = 'xxxxxxxx@gmail.com'; //Opcional, si no se usa dejar vacio entre ''
$asunto = 'xxxxxxxxxxxx';
//**********************************************//
// Parametros de mail.html, no tocar nada //
//**********************************************//
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href"); }
$email_message .= "First Name: ".clean_string($first_name)."<br>\n";
$email_message .= "Last Name: ".clean_string($last_name)."<br>\n";
$email_message .= "Email: ".clean_string($email_from)."<br>\n";
$email_message .= "Telephone: ".clean_string($telephone)."<br>\n";
$email_message .= "Comments: ".clean_string($comments)."<br>\n";
// envio de correo
$mail->Sender=$correo;
$mail->setFrom($correo, $mailer);
$mail->addAddress($enviar1, 'Eugenio'); // Add a recipient
$mail->addAddress($enviar2, ''); // Name is optional
}
// $mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $asunto;
$mail->Body = $email_message;
$mail->AltBody = $email_message;
if(!$mail->send()) {
echo 'Mensaje sin enviar.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
phpAlert("Mensaje sin enviar!\\n\\nPHP has got an Alert Box");
} else {
echo 'El mensaje fue enviado';
phpAlert("Mensaje enviado!\\n\\n");
header ('Refresh: 5; URL=email.html'); }
function phpAlert($msg) {
echo '<script type="text/javascript">alert("' . $msg . '")</script>';
}