CodeIgniter Forums
Adding Specific Configuration in CodeIgniter Email Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Adding Specific Configuration in CodeIgniter Email Class (/showthread.php?tid=69578)



Adding Specific Configuration in CodeIgniter Email Class - Kel_Novi - 12-17-2017

I'm trying to send an email in my localhost and i use codeigniter's email class function but i always encountered SSL Handshake error,so now i try PHP mailer , so now i cannot still sent email from my local computer , then i found out that in PHPmailer settings, i should add this configuration :

PHP Code:
$mail->SMTPOptions  array(
 
  'ssl' => array(
 
    'verify_peer' => false,
 
    'verify_peer_name' => false,
 
    'allow_self_signed' => true
    
)
 ); 

Now i can send email from my computer, but i would prefer to use codeigniter's email library because i dont want additional class or scripts to download

So my question , how do i add that configuration to codeigniter's email class ?

PHP Code:
array(
 
  'ssl' => array(
 
    'verify_peer' => false,
 
    'verify_peer_name' => false,
 
    'allow_self_signed' => true
    
)
 ); 



RE: Adding Specific Configuration in CodeIgniter Email Class - ivantcholakov - 12-17-2017

I don't remember whether the original CodeIgniter's email library can do this, but it can be upgraded to use PHPMailer. You may try this project of mine https://github.com/ivantcholakov/codeigniter-phpmailer , the README contains instructions about the installation.

Your application code about emails would not need modifications, leave it as it is.

Then, see the answer of this question: https://github.com/ivantcholakov/codeigniter-phpmailer/issues/14
A new configuration option has been added that is interesting for you, $config['smtp_conn_options'] .


RE: Adding Specific Configuration in CodeIgniter Email Class - InsiteFX - 12-17-2017

On localhost you need to setup the SMTP etc; in your php.ini file.

I setup my localhost to use my comcast smtp server and it works fine.


RE: Adding Specific Configuration in CodeIgniter Email Class - DenilsonPereira - 05-15-2020

(12-17-2017, 05:09 AM)InsiteFX Wrote: On localhost you need to setup the SMTP etc; in your php.ini file.

I setup my localhost to use my comcast smtp server and it works fine.

So, was I right? It was a problem with the firewall and the ports?

I get solve this problem :

Edit File System/libraries/Email.php 

function _smtp_connect
change fsockopen to stream_socket_client
$context = stream_context_create([
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false
            ]
        ]);



$this->_smtp_connect = stream_socket_client($ssl.$this->smtp_host . ':' 
                                        . $this->smtp_port,
                                        $errno,
                                        $errstr,
                                        $this->smtp_timeout,STREAM_CLIENT_CONNECT, $context);