Welcome Guest, Not a member yet? Register   Sign In
Use 2 email configuration
#4

(This post was last modified: 11-06-2017, 11:39 AM by ivantcholakov. Edit Reason: fixing a directory name )

I got interested on how I would do this and here is something I've just tested.

1. Create within the config/ folder two configuration files, email.php and email_2.php and fill them with the corresponding data for the two email accounts.

2. Within libraries/ directory create a file Email_2.php with the following content:
Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

get_instance()->load->library('email');

// This name could be 'CI_Email' or 'MY_Email', or something else as a result.
$_email_class_name = get_class(get_instance()->email);

class_alias($_email_class_name, '_Email_2');

class Email_2 extends _Email_2 {

}

3. Within the controller Welcome.php or other controller test with this fragment of code:
Code:
$this->load->library('email');
        var_dump(get_object_vars($this->email));

        echo '<br />';

        $this->load->library('email_2');
        var_dump(get_object_vars($this->email_2));

You would see that both library instances have different properties, according to their configuration files.
Reply


Messages In This Thread
Use 2 email configuration - by serialkiller - 10-31-2017, 01:18 AM
RE: Use 2 email configuration - by dave friend - 10-31-2017, 08:47 AM
RE: Use 2 email configuration - by serialkiller - 11-06-2017, 08:14 AM
RE: Use 2 email configuration - by ivantcholakov - 11-06-2017, 11:38 AM
RE: Use 2 email configuration - by serialkiller - 11-07-2017, 08:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB