0
votes

I try to send a local email with codeIgniter.

// envoi du mail
 public function envoiMail(){
    $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => '[email protected]',
        'smtp_pass' => 'XXXXXX',
        'mailtype'  => 'html',
        'charset'   => 'iso-8859-1',
        'crlf'   => '\r\n',
        'newline'   => '\r\n',
    );
    $sujet = $this->input->post('sujet');
    $message = $this->input->post('message');
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    $this->email->from('[email protected]', 'Name');
    $this->email->to('[email protected]');
    $this->email->subject($sujet);
    $this->email->message($message);
    $this->email->send();
  if($this->email->send()){
      // mail transmis
       echo "ok";
  }else{
      // erreur de transmission
      echo"erreur d'envoi";
  }
 }

when I test I get this error: Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.

4

4 Answers

0
votes

try to update your config to something like this:

 $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'smtp.googlemail.com',
        'smtp_port' => '587',
        'smtp_user' => '[email protected]',
        'smtp_pass' => 'XXXXXX',
        'mailtype'  => 'html',
        'charset'   => 'iso-8859-1',
        'crlf'   => '\r\n',
        'newline'   => '\r\n',
    )
0
votes
$config = array(
                'protocol'  => 'smtp',
                'smtp_host' => 'ssl://smtp.googlemail.com',
                'smtp_port' => 465,
                'smtp_user' => '[email protected]',
                'smtp_pass' => 'your password',
                'mailtype'  => 'html',
                'charset'   => 'utf-8'
            );

Try this....

0
votes

If you are using Avast Antivirus disable it.

In my case the Avast Antivirus was blocking the port, I was using the SMTP Port 465 for sending an email from my Codeigniter Project.

Simply disabling the avast antivirus solves the situation.

0
votes

In case you are on a shared hosting server, most of the times the ports 25 and 587 will remain blocked. This block is been purposely done by your hosting provider and in case you are using your local machine, then the antivirus/firewall will by default block these port.

In these cases, you will either get connection timeout or socket connection error.

When these ports are blocked, try to connect using port 2525. If you find that port is also blocked, then the only solution is to contact your hosting provider to unblock these ports or disable/edit firewall/antivirus rules.

Most of the hosting providers/antivirus/firewalls by default block these email ports to protect their network from sending any type of spam emails.