Welcome Guest, Not a member yet? Register   Sign In
trigger send mail with Ajax not working
#1

[eluser]elaniobro[/eluser]
I've gotten pretty far with this. I got the page making the ajax call.

Prior to putting ajax in, sending an e-mail was no problem. Once I put it in, it no longer sends. It will still validate, however if you pass the validation, it will just load the success view and not send an e-mail.

controller:
Code:
<?php
    class Email extends Controller
    {
    
        function Email()
        {
            parent::Controller();    
        }
        
        function index()
        {
            $this->load->view('email_view');    
        }
        
        function send()
        {
            
            $this->load->library('form_validation');
            
            //field name, error message, validation rules
            $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email');
            $this->form_validation->set_rules('fullName', 'full name', 'trim|required|min_length[5]');
            
            if($this->form_validation->run() == FALSE)
            {
                
                $this->load->view('email_view');
                
            }else{
                //validaiton has past, send e-mail
                $fullName = $this->input->post('fullName');
                $email = $this->input->post('email');
                $subject = $this->input->post('subject');
                $message = $this->input->post('message');
            
                $config = Array(
                            'protocol' => 'sendmail',
                            'smtp_host' => 'smtp.example.com',
                            'smtp_port' => 143,
                            'smtp_user' => '[email protected]',
                            'smtp_pass' => 'start123'    
                                );
                $this->load->library('email');
    
                $this->email->from($email, $fullName);
                $this->email->to('[email protected]');            
                $this->email->subject($subject);
                $this->email->message($message);
                
                $this->load->library('email', $config);
                $this->email->set_newline("\r\n");
                
                if($this->input->post('ajax'))
                {
                    $this->load->view('emailSucess_view');
                }else{
                    $this->load->view('email_view');
                }
            
            
    
            }
        }
    }
?>


Messages In This Thread
trigger send mail with Ajax not working - by El Forum - 03-17-2010, 09:17 AM
trigger send mail with Ajax not working - by El Forum - 03-17-2010, 09:18 AM
trigger send mail with Ajax not working - by El Forum - 03-17-2010, 09:59 AM
trigger send mail with Ajax not working - by El Forum - 03-17-2010, 10:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB