Do not send form to mail (library CodeIgniter)

0

Good morning I have a form that I want to send to my email

  

Form

<div class="col-lg-5">
    <div class="contact-box m-l-30">
        <h1 class="title font-light m-t-10">Contáctanos</h1>
        <form id="form_contactanos" class="m-t-30" data-aos="fade-left" data-aos-duration="1200">
            <!-- Do not remove this code. -->
            <input type='text' style='display:none;' name='xnQsjsdp' value='b8c6293891e2878f125a78c114c45d1133cd8ab0fd31519fb0e76a930012c594'/>
            <input type='hidden' name='zc_gad' id='zc_gad' value=''/>
            <input type='text' style='display:none;' name='xmIwtLD' value='8a7419917526917cd8f7bdba23036d4e76dd2fe5acde48ea54eca87191bb89af'/>
            <input type='text' style='display:none;'  name='actionType' value='TGVhZHM='/>

            <input type='text' style='display:none;' name='returnURL' value='https&#x3a;&#x2f;&#x2f;www.abanet.net' /> 
            <!-- Do not remove this code. -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="form-group m-t-10">
                        <input id="txt_nombre" name="txt_nombre" class="form-control" type="text" placeholder="Nombre"> </div>
                </div>
                <div class="col-lg-12">
                    <div class="form-group m-t-10">
                        <input id="txt_puesto" name="txt_puesto" class="form-control" type="text" placeholder="Tu Puesto"> </div>
                </div>
                <div class="col-lg-12">
                    <div class="form-group m-t-10">
                        <input id="txt_giro" name="txt_giro" class="form-control" type="text" placeholder="Giro de la Empresa"> </div>
                </div>
                <div class="col-lg-12">
                    <div class="form-group m-t-10">
                        <input id="txt_ubicacion" name="txt_ubicacion" class="form-control" type="text" placeholder="Ubicación"> </div>
                </div>
                <div class="col-lg-12">
                    <div class="form-group m-t-10">
                        <input id="txt_telefono" name="txt_telefono" class="form-control" type="text" placeholder="Teléfono"> </div>
                </div>
                <div class="col-lg-12">
                    <div class="form-group m-t-10">
                        <textarea id="txt_mensaje" name="txt_mensaje" class="form-control" rows="3" placeholder="Mensaje"></textarea>
                    </div>
                </div>
                <div class="col-lg-12">
                    <div id="recaptcha" class="g-recaptcha" data-sitekey="6LctHHEUAAAAAP99bIMWKIoyMLzEaFnsz0XF2Tpx"></div>
                </div>
                <div class="col-lg-12">
                    <button type="button" onclick="enviar_password()" class="btn btn-info-gradiant btn-md m-t-20 btn-arrow"><span> ENVIAR <i class="ti-arrow-right"></i></span></button>
                </div>
            </div>
        </form>
    </div>
</div>
  

Form executes JavaScript function send_password ()

function enviar_password() {
          var $captcha = $( '#recaptcha' ),
              response = grecaptcha.getResponse();

          if (response.length === 0) {
            swal("Algo salió mal!", "Valida el reCAPTCHA por favor!", "error");
          } else {
            $.ajax({
                url : '<?php echo base_url('index.php/Inicio_controller/enviar_mensaje')?>',
                type: "POST",
                data: $('#form_contactanos').serialize(),
                dataType: "JSON",
                success: function(data){
                    grecaptcha.reset();
                    document.getElementById("form_contactanos").reset(); 
                    swal("Buen trabajo!", "Tu mensaje ha sido enviado!", "success");
                },
                error: function (jqXHR, textStatus, errorThrown){
                    swal("Algo salió mal!", "Error al enviar tu mensaje!", "error");
                }
            });
          }
        }
  

The AJAX if it enters the controller

public function enviar_mensaje() {

  $nombre = $this->input->post('txt_nombre');
  $puesto = $this->input->post('txt_puesto');
  $giro = $this->input->post('txt_giro');
  $ubicacion = $this->input->post('txt_ubicacion');
  $telefono = $this->input->post('txt_telefono');
  $mensaje = $this->input->post('txt_mensaje');

  $from_email = "[email protected]";
  $from_password = 'password';

  $to_email = '[email protected]';

  $config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => $from_email,
    'smtp_pass' => $from_password,
    'mailtype'  => 'html', 
    'charset'   => 'utf-8'
  );

  $this->load->library('email', $config);
  $this->email->set_newline("\r\n");

  $this->email->from($from_email, 'abacom Telecomunicaciones');
  $this->email->to($to_email);
  $this->email->subject('Cotizacion Web');
  $this->email->message('hola');
  //Send mail
  if($this->email->send()){
      echo json_encode(array("status" => TRUE));
  }
}

The controller is returning TRUE but the mail is not arriving. They have some idea why it is not coming to me. Of formal local if it arrives but when the amount to the hosting the mail does not work.

I hope you can help me

    
asked by Javier fr 06.12.2018 в 16:57
source

0 answers