Advertisement
Guest User

Untitled

a guest
Feb 9th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. <?php
  2.  
  3. class ContactoController extends BaseController {
  4. /* Controlador para validación de datos y mandar un correo de contacto a determinado correo
  5.  
  6. */
  7.  
  8. public function mandarContacto(){
  9.  
  10.  
  11.  
  12. $rules = array(
  13. 'txtNombre' => 'required|min:5',
  14. 'txtCorreo' => 'required|min:5',
  15. 'txtTel' => 'required|min:7',
  16. 'txtMensaje' => 'required|min:10',
  17. );
  18.  
  19. $validator = Validator::make(Input::all(), $rules);
  20.  
  21. if ($validator->fails()) {
  22.  
  23.  
  24. Session::flash('captcha', 'Por favor, llene los campos correctamente.');
  25. return Redirect::to("contacto");
  26.  
  27. } else {
  28.  
  29.  
  30.  
  31.  
  32. $name = Input::get('txtNombre');
  33. $email = Input::get('txtCorreo');
  34. $telefono = Input::get('txtTel');
  35. $mensaje = Input::get('txtMensaje');
  36.  
  37.  
  38.  
  39. $correo = Input::get('cboNivel');
  40.  
  41.  
  42. $body = "";
  43. $body .= "name: ".$name."<br />";
  44. $body .= "mail: ".$email."<br />";
  45. $body .= "phone: ".$telefono."<br />";
  46. $body .= "mensaje: ".$mensaje."<br />";
  47. $body .= "Instituto Gardner Cozumel <br />";
  48.  
  49.  
  50. require 'mailer/PHPMailerAutoload.php';
  51.  
  52. $mail = new PHPMailer;
  53. $mail->Host = "smtpout.secureserver.net";
  54. $mail->SMTPDebug = 2;
  55. $mail->SMTPAuth = true;
  56. $mail->Port = 80;
  57. $mail->Username = "dmas@consultoresemkt.com";
  58. $mail->Password = "";
  59. // $mail->AddAddress('dmas@consultoresemkt.com');
  60. $mail->AddAddress('dmas@consultoresemkt.com');
  61. $mail->AddAddress($correo);
  62. // $mail->AddAddress('reservations@safetourscozumel.com');
  63. // $mail->AddAddress('safetourscozumel@gmail.com');
  64. $mail->Subject="Contacto - Instituto Gardner Cozumel";
  65.  
  66. $mail->SetFrom($email, $email);
  67. $mail->MsgHTML($body);
  68.  
  69.  
  70. if (!$mail->send()) {
  71. //echo "Mailer Error: " . $mail->ErrorInfo;
  72. Session::flash('captcha', 'The mail was not sent, please try again');
  73. // return false;
  74. } else {
  75. //echo "Enviado";
  76. Session::flash('captcha', 'El correo se envio correctamente!!!!!');
  77. // return true;
  78. }
  79.  
  80. return Redirect::to("contacto");
  81.  
  82. }
  83.  
  84.  
  85. }
  86.  
  87.  
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement