CodeIgniter Forums

Full Version: email send error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I developing a website, where in an admin page have a button which processing an email send (to admin).

This is the configuration:


PHP Code:
   $this->load->library('encrypt');
 
   $config = array(
 
       'protocol' => 'smtp'// 'mail', 'sendmail', or 'smtp'
 
       //'useragent' => 'CodeIgniter',
 
       'smtp_host' => 'smtp.mail.yahoo.com',
 
       'smtp_port' => 465,
 
       'smtp_user' => '****',
 
       'smtp_pass' => '****',
 
       'smtp_crypto' => 'ssl'//can be 'ssl' or 'tls' for example
 
       'mailtype' => 'html'//plaintext 'text' mails or 'html'
 
       'charset' => 'iso-8859-1',
 
       'wordwrap' => TRUE,
 
   );
 
   $this->load->library('email'$config); 

I try with different configurations:
  • gmail with SSL, with TLS, with different 'smtp_host' like with and without ssl://
  • different gmails with @gmail.com and with another one which is not @gmail.com
  • yahoo mail with ssl
  • different PHP versions like 5.6 and 7.1
  • enable less secure apps in gmail/yahoomail
And this is the function:

PHP Code:
 public function send_email(){
 
   $from $this->config->item('smtp_user');
 
   $to '****';

 
   $this->email->from($from);
 
   $this->email->to($to);
 
   $this->email->set_newline("\r\n");
 
   $this->email->subject('szerkesztési jog igénylése');
 
   $this->email->message(
 
     'Tisztelt adminisztrátor!\r\n
      \r\n
      Egy felhasználó szerkesztési jogot szeretne igényelni a Faipari szakszótárhoz\r\n
      Kérjük jelentkezz be, és bíráld el a szerkesztési jogát az igénylőnek'
 
   );

 
   if ($this->email->send()) {
 
     $this->session->set_flashdata('uzenet''Sikeres szerkesztési jog igénylés');
 
     redirect('pages/user'$data);
 
   } else {
 
     show_error($this->email->print_debugger());
 
   }
 
 
I got different error codes for different cases, but nothing made solution after few hours google search and reading threads.


With yahoo/ssl:

Quote:Severity: Warning
Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Filename: libraries/Email.php

Severity: Warning
Message: fsockopen(): Failed to enable crypto

Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.mail.yahoo.com:465 (Unknown error)

The following SMTP error was encountered: 0
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

With gmail/ssl:

Quote:A PHP Error was encountered
Severity: Warning
Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

With gmail/tls:

Quote:A PHP Error was encountered
Severity: Warning
Message: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

An Error Was Encountered
220 smtp.gmail.com ESMTP u9sm5539564wmd.14 - gsmtp

Have you any idea what can solution this problem? My codeigniter version is 3.1.7
Does your server have a SSL certificate in place?