Welcome Guest, Not a member yet? Register   Sign In
email class
#1

[eluser]HooJee[/eluser]
Hi Guys

Is there any way I can use standard "php mail" using the email class ?
#2

[eluser]Johan André[/eluser]
What do you mean?

The email-class uses the php-mailfunctions.
#3

[eluser]HooJee[/eluser]
Well, the problem is SMTP and sendmail are not working. I have been working very closely with my host and even they cannot get it to work.
#4

[eluser]HooJee[/eluser]
Ok, host has tried to diagnose the problem to no avail. I will try to explain exactly what Im doing here, maybe there is a problem with the code itself. I have a contact page with name, email and comment fields. Its ajax based and the post request is made successfully, but whenever an attempt to send an email is made firebug returns nothing (no error from the debugger nor the success message). See code below:

// Controller code
Code:
function send() {
    // SET VARIABLES
    $response = array('type'=>'');
    
    // LOAD LIBRARIES
    $this->load->library('form_validation', 'email');
    
    //SETUP VALIDATION RULES
    $this->form_validation->set_rules('name', 'Name', 'required|min_length[1]');
    $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
    $this->form_validation->set_rules('comments', 'Comments', 'required|min_length[5]');

    if ($this->form_validation->run())
    {            
        // GET POST VARIABLES
        $name = $this->input->post('name');
        $email = $this->input->post('email');
        $comments = $this->input->post('comments');

        // send email            
        $this->email->from($email, $name);
        $this->email->to('[email protected]');

        $this->email->subject('Message sent from Shad.com');
        $this->email->message($comments);

        if (!$this->email->send()) {
            show_error($this->email->print_debugger());
        } else {
            echo 'Your e-mail has been sent!';
        }
    }
    else
    {
        // Print Error Msg
        $response['type'] = 'failed';
        $encoded_data = json_encode($response);
        echo $encoded_data;
    }
}

// config/email.php
Code:
// note I have tried both SMTP and sendmail to no avail
//smtp
<?php
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'localhost';
$config['email_address'] = '[email protected]';
$config['email_name'] = 'www.mysite.com';
?>

// and sendmail method
<?php
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
?>
#5

[eluser]eokorie[/eluser]
Hi

I don't know if this might help but I did have a few issues getting smtp to work on with my own host until I changed the protocol from smtp to smtps.

Try that and see if that works.




Theme © iAndrew 2016 - Forum software by © MyBB