Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ContactoController extends BaseController {
- /* Controlador para validación de datos y mandar un correo de contacto a determinado correo
- */
- public function mandarContacto(){
- $rules = array(
- 'txtNombre' => 'required|min:5',
- 'txtCorreo' => 'required|min:5',
- 'txtTel' => 'required|min:7',
- 'txtMensaje' => 'required|min:10',
- );
- $validator = Validator::make(Input::all(), $rules);
- if ($validator->fails()) {
- Session::flash('captcha', 'Por favor, llene los campos correctamente.');
- return Redirect::to("contacto");
- } else {
- $name = Input::get('txtNombre');
- $email = Input::get('txtCorreo');
- $telefono = Input::get('txtTel');
- $mensaje = Input::get('txtMensaje');
- $correo = Input::get('cboNivel');
- $body = "";
- $body .= "name: ".$name."<br />";
- $body .= "mail: ".$email."<br />";
- $body .= "phone: ".$telefono."<br />";
- $body .= "mensaje: ".$mensaje."<br />";
- $body .= "Instituto Gardner Cozumel <br />";
- require 'mailer/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->Host = "smtpout.secureserver.net";
- $mail->SMTPDebug = 2;
- $mail->SMTPAuth = true;
- $mail->Port = 80;
- $mail->Username = "dmas@consultoresemkt.com";
- $mail->Password = "";
- // $mail->AddAddress('dmas@consultoresemkt.com');
- $mail->AddAddress('dmas@consultoresemkt.com');
- $mail->AddAddress($correo);
- // $mail->AddAddress('reservations@safetourscozumel.com');
- // $mail->AddAddress('safetourscozumel@gmail.com');
- $mail->Subject="Contacto - Instituto Gardner Cozumel";
- $mail->SetFrom($email, $email);
- $mail->MsgHTML($body);
- if (!$mail->send()) {
- //echo "Mailer Error: " . $mail->ErrorInfo;
- Session::flash('captcha', 'The mail was not sent, please try again');
- // return false;
- } else {
- //echo "Enviado";
- Session::flash('captcha', 'El correo se envio correctamente!!!!!');
- // return true;
- }
- return Redirect::to("contacto");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement