i try to create my custom email config file that includes my email server configuration.
i created it under /config directory and the code is below:
<?php
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '[email protected]',
'smtp_pass' => '*************',
'mailtype' => 'html'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
?>
and in order to use it i call in my kayit.php's which is a controller constructor
$this->config->load('email');
However, i get an error like that
I quote from the manual:
If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the email.php, add the $config array in that file. Then save the file at config/email.php
The config file is just AN ARRAY (named $config), and being only that it doesn't have access to the $this reference. The code you're using (loading a library, for example) has to be inside a controller, not inside the config file!
Since this config file is for the built-in email class, it will be auto-loaded if it's called config/email.php
.
If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the
email.php
, add the$config array
in that file. Then save the file atconfig/email.php
and it will be used automatically. You will NOT need to use the$this->email->initialize()
function if you save your preferences in a config file.
You cannot (why would you) call $this->load
inside a config file.
Also, you cannot declare config files like that. $config = Array(
, you are overwriting all other values in $config
. You need to declare each option individually.
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = '*************';
$config['mailtype']= 'html';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With