0

I have sendmail installed on a CentOS 6 server that seems to work well given that I can send a test message using CLI.

However, when trying to send a test message using CodeIgniter's email class, there seems to be some problem. My email.php config is

$config['protocol'] = 'sendmail';
$config['mailtype'] = 'html';
$config['charset']  = 'utf-8';
$config['newline']  = "\r\n";

The controller for testing email:

    $this->load->library('email');

    $this->email->from('your@example.com', 'from name');
    $this->email->to('someone@somewhere.com');

    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');

    $this->email->send();
    echo $this->email->print_debugger();

When I send the test message through CodeIgniter, I get this error message

Exit status code: 71
Unable to open a socket to Sendmail. Please check settings.
Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.

When switching to SMTP or mail in the config I still get errors.

Any suggestions where to start trying to troubleshoot this problem?

pepe
  • 9,145
  • 24
  • 100
  • 177

4 Answers4

0

I don't see that you are initializing the mail configuration. Try adding $this->email->initialize($config);

lfontana
  • 29
  • 5
  • the library is being loaded (see first line) and loading the config. As mentioned in OP, wen I change config parameters I see a change in the errors (eg using mail or SMTP), but I want to use sendmail – pepe Oct 26 '15 at 23:42
  • 1
    @torr he means to say you loaded the library but not passed config array to `$this->load->library('email', $config);` – Linus Oct 26 '15 at 23:46
  • yes but the config is in the config.php file, not inline within the controller – pepe Oct 26 '15 at 23:47
0

Try Something like this

  $this->load->library('email');
                $config['protocol']='smtp';
                $config['smtp_host']='your host';
                $config['smtp_port']='465';
                $config['smtp_timeout']='30';
                $config['smtp_user']='your mail id';
                $config['smtp_pass']='your password';
                $config['charset']='utf-8';
                $config['newline']="\r\n";
                $config['mailtype'] = 'html';
                $this->email->initialize($config); //intializing config array 
                $this->email->from('your@example.com', 'Site name');
                $this->email->to('someone@somewhere.com');
                $this->email->subject('Mail');
                $this->email->message('Your message');
                $this->email->send();
Linus
  • 869
  • 3
  • 20
  • 31
  • what are "your mail id" and "your password" supposed to be? those for my server or something specific for SMTP? i don't recall setting up any user/pwd for SMTP – pepe Oct 26 '15 at 23:37
  • @torr it will be your email_id and password – Linus Oct 26 '15 at 23:44
  • I'm sorry anmol but I don't follow, can you explain further – pepe Oct 26 '15 at 23:45
  • @torr did you set smtp_host in config array?? – Linus Oct 26 '15 at 23:47
  • @torr refer this http://stackoverflow.com/questions/1555145/sending-email-with-gmail-smtp-with-codeigniter-email-library and http://stackoverflow.com/questions/11652991/sending-email-with-codeigniter-using-mail-or-sendmail – Linus Oct 27 '15 at 00:02
0
 $config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '******@gmail.com',
'smtp_pass' => '**********',
'mailtype'  => 'html', 
'charset' => 'utf-8',
'wordwrap' => TRUE
 );           
        //send email with #temp_pass as a link
       $this->load->library('email', $config);
       $this->email->set_newline("\r\n");
        $this->email->from('**********@gmail.com', "Title");
        $this->email->to($email);
        $this->email->subject("Added");

        $message = "<p>This email has been sent as a request to added</p>";
        $this->email->message($message);
        $this->email->send();
B.Nadesh kumar
  • 196
  • 1
  • 10
0

Try these.

  1. Make sure apache is added to smmsp group.

    id apache

If note add to group

usermod -g smmsp apache
  1. chmod -v 2755 /usr/sbin/sendmail.sendmail

  2. change config['mailpath'] to /use/sbin/sendmail.sendmail

If these tweeks didn't work,

  1. chmod 777 /var/spool/clientmqueue Its a security risk link
Shanavas M
  • 1,073
  • 13
  • 16