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

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.

    class Email extends Controller
        function Email()
        function index()
        function send()
            //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)
                //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->email->from($email, $fullName);
                $this->email->to('[email protected]');            
                $this->load->library('email', $config);

<div class="popup-container" id="contact-container">
                        <div class="watermark">
                        <div class="close">
                            &lt;?= anchor('',
                        <div class="clear"></div>
                            <div id="contact-form">
                                <div class="title">
                                    &lt;?= img(array('src'=>'img/footer/contact/trybuch_title_contact.gif','alt'=>'Contact Form'));?&gt;
                                &lt;?= form_open('email/send');?&gt;
                                <p>&lt;input&gt;&lt;label class="contact-label">email</label></p>
                                <p>&lt;input&gt;&lt;label class="contact-label">full name</label></p>
                                <p>&lt;input&gt;&lt;label class="contact-label">subject</label></p>
                                <p>&lt;textarea&gt;So tell me what is on your mind....&lt;/textarea&gt;&lt;/p>
                                &lt;?= form_submit('submit','Send','id="submit"');?&gt;
                                &lt;?= form_close();?&gt;
                                &lt;?= validation_errors('<p class="contact-error">');?&gt;

                            var contact_data =
                                fullName: $('#fullName').val(),
                                email: $('#email').val(),
                                subject: $('#subject').val(),
                                message: $('#message').val(),
                                ajax: '1'
                                url: "&lt;?php echo site_url('email/send');?&gt;",
                                type: 'POST',
                                data: contact_data,
                                success: function(msg){
                            return false;

You seem to be missing $this->email->send() within your send function.

[quote author="Kamarg" date="1268859577"]You seem to be missing $this->email->send() within your send function.[/quote]

oh man, thanks for that.. I guess I deleted that line accidentally and did not notice when I started implementing the ajax Tongue

It is usually the most obvious. Thanks Kamarg!


Theme © iAndrew 2016 - Forum software by © MyBB