Foros del Web » Programando para Internet » PHP »

como enlazar formulario con correo electronico

Estas en el tema de como enlazar formulario con correo electronico en el foro de PHP en Foros del Web. hola buenas gente aqui a pedirles un gran favor por favor alguien sabe como enlazar un formulario para que llegue al correo prederteminado el codigo ...
  #1 (permalink)  
Antiguo 25/09/2015, 07:44
Avatar de joseherran  
Fecha de Ingreso: septiembre-2015
Ubicación: cali valle
Mensajes: 23
Antigüedad: 8 años, 7 meses
Puntos: 0
Exclamación como enlazar formulario con correo electronico

hola buenas gente aqui a pedirles un gran favor por favor alguien sabe como enlazar un formulario para que llegue al correo prederteminado el codigo lo tiene hace la validacion pero cuando llega a la base de datos se queda hay y no envia al correo por favor si alguien sabe aque se debe ese error por favor aqui esperare las respuesta gracias utilizo el framework codeignater gracias
  #2 (permalink)  
Antiguo 25/09/2015, 08:39
Avatar de joseherran  
Fecha de Ingreso: septiembre-2015
Ubicación: cali valle
Mensajes: 23
Antigüedad: 8 años, 7 meses
Puntos: 0
Respuesta: como enlazar formulario con correo electronico

Código PHP:
Ver original
  1. /*
  2.      *Enviar correo
  3.      */
  4.  
  5.     function send()
  6.     {
  7.         $this->form_validation->set_rules('name', 'Nombre y Apellido', 'required|trim|max_length[100]');
  8.         $this->form_validation->set_rules('email', 'Correo', 'required|trim|valid_email|max_length[100]');
  9.         $this->form_validation->set_rules('phone', 'Teléfono', 'trim|max_length[30]');
  10.         $this->form_validation->set_rules('cell', 'Celular', 'trim|max_length[30]');
  11.         $this->form_validation->set_rules('company', 'Empresa/Organización', 'trim|max_length[100]');
  12.         $this->form_validation->set_rules('message', 'Mensaje', 'required|trim|max_length[455]');
  13.        
  14.         $statusJson = 'error';
  15.         $msgJson = 'Por favor intenta de mas tarde';
  16.        
  17.         if ($this->form_validation->run() === TRUE)
  18.         {
  19.             $post = (object) $this->input->post(null);
  20.  
  21.             $email = $this->db->where('id', $post->id_email_area)->get('contact_us_emails_area')->row();
  22.            
  23.             // si el correo viene separado por ,
  24.             if (count($email) > 0)
  25.             {
  26.                 $email = $email->email;
  27.                 if (strpos($email,',') !== false)
  28.                 {
  29.                     $emails = explode(",", $email);
  30.                 }
  31.             }
  32.  
  33.             $email = $this->db->get('contact_us')->row()->email;
  34.             //echo $email;
  35.             setlocale(LC_ALL, "es");
  36.             date_default_timezone_set('America/Bogota');
  37.  
  38.             $data['post'] = array(
  39.                 'name' => $post->name,
  40.                 'email' => $post->email,
  41.                 'phone' => $post->phone,
  42.                 'cell' => $post->cell,
  43.                 'company' => $post->company,
  44.                 'city' => $post->city,
  45.                 'message' => $post->message,
  46.                 'cotizacion' => $post->cotizacion,
  47.                 'date' => date('Y-m-d H:i:s'),
  48.                 'lang' => $this->lang_code
  49.             );
  50.  
  51.            //Validate sendmail
  52.             if( $this->contact_us_emails_m->insert($data['post']))
  53.             {
  54.                 // si estan separados por , mandamos los correos si no mandamos 1 solo
  55.                 if(strpos($email,',') !== false && !empty($emails) && count($emails) > 0)
  56.                 {
  57.                     foreach($emails AS $row => $value)
  58.                     {
  59.                         $this->send_email_to_user($data['post'], $value);
  60.                     }
  61.                 }
  62.                 else
  63.                 {
  64.                     $this->send_email_to_user($data['post'], $email);
  65.                 }
  66.                 $statusJson = '';
  67.                 $msgJson = 'Su mensaje ha sido enviado';
  68.             }
  69.             else
  70.             {
  71.                 $statusJson = 'error';
  72.                 $msgJson = 'Error Mailing, Contact the Webmaster';
  73.             }
  74.         } else
  75.         {
  76.             $statusJson = 'error';
  77.             $msgJson = validation_errors();
  78.         }
  79.         echo json_encode(array('status' => $statusJson, 'msg' => $msgJson));
  80.     }
  81.  
  82.     public function detail($slug) {
  83.  
  84.         $return = $this->google_map_model->get_many_by('slug', $slug);
  85.         $return = $return[0];
  86.  
  87.         if (!$return)
  88.             redirect('google_maps');
  89.  
  90.         // Se convierten algunas variables necesarias para usar como slugs
  91.         $setter = array(
  92.             'image' => val_image($return->image),
  93.         );
  94.  
  95.         $google_map = array_merge((array) $return, $setter);
  96.  
  97.         $relation = $this->db->where('google_map_id', $google_map['id'])->get('google_maps_categories')->result();
  98.         $categories = array();
  99.         foreach ($relation as $item) {
  100.             $category = $this->google_map_category_model->get_many_by('id', $item->category_id);
  101.             $category = $category[0];
  102.             $categories[] = array(
  103.                 "title" => $category->title,
  104.                 "slug" => $category->slug
  105.             );
  106.         }
  107.  
  108.         // imagenes para slider
  109.         $images = $this->google_map_image_model->get_many_by('google_map_id', $google_map['id']);
  110.  
  111.         // datos para el mapa de google
  112.         // mandamos los puntos
  113.         $json_markers = json_encode(array(array($google_map['adress'] . ', Prueba-Cali', (double) $google_map['coordinate1'], (double) $google_map['coordinate2'])));
  114.  
  115.         // sacamos solo el nombre de la imagen
  116.         $imageTogoogle = str_replace(site_url() . 'uploads/default/' . $this->moduleName . '/', "", $google_map['image']);
  117.  
  118.         // mandamos los datos para el modal dentro del mapa
  119.         $json_info_content = json_encode(array(array('image' => $imageTogoogle, 'adress' => $google_map['adress'], 'title' => $google_map['name'], 'moduleName' => $this->moduleName, 'schedule' => $google_map['schedule'], 'description' => $google_map['description'])));
  120.  
  121.         $this->template
  122.                 ->append_js('module::google_maps.js')
  123.                 ->set('json_info_content', $json_info_content)
  124.                 ->set('json_markers', $json_markers)
  125.                 ->set('google_map', (object) $google_map)
  126.                 ->set('categories', $categories)
  127.                 ->set('images', $images)
  128.                 ->build('detail');
  129.     }
  130.  
  131.     public function multiple_poins() {
  132.         $json_markers = array();
  133.         $json_info_content = array();
  134.         $statusJson = 'error';
  135.         $msgJson = 'Ocurrio un error al cargar los datos de google, porfavor intente más tarde';
  136.  
  137.         if (isset($_POST['idcategory'])) {
  138.             $idCategory = $_POST['idcategory'];
  139.  
  140.             $google_map = $this->db
  141.                             ->select('*')
  142.                             ->from('google_maps AS gm')
  143.                             ->join('google_maps_categories AS gc', 'gc.google_map_id = gm.id', 'left')
  144.                             ->where('gc.category_id', $idCategory)
  145.                             //->limit($pagination['limit'], $pagination['offset'])
  146.                             ->get()->result();
  147.  
  148.             if (!empty($google_map)) {
  149.                 foreach ($google_map AS $item) {
  150.                     $item->image = val_image($item->image);
  151.                     array_push($json_markers, array($item->adress . ', ' . $item->name, (double) $item->coordinate1, (double) $item->coordinate2));
  152.  
  153.                     $imageTogoogle = str_replace(site_url() . 'uploads/default/' . $this->moduleName . '/', "", $item->image);
  154.  
  155.                     array_push($json_info_content, array('image' => $imageTogoogle, 'adress' => $item->adress, 'title' => $item->name, 'moduleName' => $this->moduleName, 'schedule' => $item->schedule, 'description' => $item->description));
  156.                 }
  157.             }
  158.             $statusJson = '';
  159.             $msgJson = 'datos de google cargados correctamente';
  160.         }
  161.         // mandamos los puntos
  162.         $json_markers = json_encode($json_markers);
  163.  
  164.         // mandamos los datos para el modal dentro del mapa
  165.         $json_info_content = json_encode($json_info_content);
  166.  
  167.         echo json_encode(array('status' => $statusJson, 'msg' => $msgJson, 'json_markers' => $json_markers, 'json_info_content' => $json_info_content));
  168.     }
  169.  
  170.     /**
  171.      * Send an email
  172.      *
  173.      * @param array $comment The comment data.
  174.      * @param array $entry The entry data.
  175.      * @return boolean
  176.      */
  177.     private function send_email_to_user($data, $admin_email) {
  178.         $this->load->library('email');
  179.         $this->load->library('user_agent');
  180.  
  181.         return Events::trigger('email', array(
  182.             'name' => $data['name'],
  183.             'email' => $data['email'],
  184.             'phone' => $data['phone'],
  185.             'company' => $data['company'],
  186.             'city' => $data['city'],
  187.             'products' => $products,
  188.             'message' => $data['message'],
  189.             'cotizacion' => $data['cotizacion'],
  190.             'slug' => 'contact',
  191.             'to' => Settings::get('contact_email'),
  192.                 ), 'array');
  193.     }
  194.  
  195.  
  196. }

Etiquetas: correo, electronico, enlazar, formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:55.