php - Codeigniter email class not working

854

I tried the code below. At one time the code was working fine. I was able to send the emails. After a few minutes, when I tried it again without even changing anything, I get this error messageUnable to send email using PHP mail(). Your server might not be configured to send mail using this method.

I dont know whats wrong. Lately I am facing a lot of similar bugs with codeigniter.

public function email($message = NULL, $subject=NULL, $email=NULL){
        if(!isset($email)){
            $to = $this->session->userdata('email');
        }else{
            $to = $email;
        }
        $this->load->library('email');


        $this->email->from('[email protected]', 'Mydomain');
        $this->email->to($to); 

        $this->email->subject($subject);
        $this->email->message($message);    

        $this->email->send();
    }
230

Answer

Solution:

i face this problem and work hard and i find solution this

just little change in email config its working 100%


 $config['protocol'] = 'ssmtp';
 $config['smtp_host'] = 'ssl://ssmtp.gmail.com';
641

Answer

Solution:

I added the following lines and the mail is working again.

$config['protocol'] = 'sendmail';
            $config['mailpath'] = '/usr/sbin/sendmail';
            $config['charset'] = 'iso-8859-1';
            $config['wordwrap'] = TRUE;

            $this->email->initialize($config);

People are also looking for solutions to the problem: php - Jquery .autocomplete not working after ajax call

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.