Welcome Guest, Not a member yet? Register   Sign In
env file and Settings package
#1

Hello everyone, 
I have a question about the priority of configuration methods. If I use both env file and offical Settings Package, which config will be used in codeigniter library. 
For example, if I set different smtphost in env file and service('settings'), which one will be used as default value in email library?
Reply
#2

I found that the email library will not use the Settings package. How should I do to use Settings (from DB) as default config in email library?
Reply
#3

Load your own email config from settings.

PHP Code:
$config = [
    'protocol' => service('settings')->get('email.protocol'), // sendmail
    'mailPath' => service('settings')->get('email.mailPath'), // /usr/sbin/sendmail
    'charset'  => service('settings')->get('email.charset'),  // iso-8859-1
    'wordWrap' => service('settings')->get(email.wordWrap),  // true
};

$email->initialize($config); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(09-22-2024, 10:25 PM)InsiteFX Wrote: Load your own email config from settings.

PHP Code:
$config = [
    'protocol' => service('settings')->get('email.protocol'), // sendmail
    'mailPath' => service('settings')->get('email.mailPath'), // /usr/sbin/sendmail
    'charset'  => service('settings')->get('email.charset'),  // iso-8859-1
    'wordWrap' => service('settings')->get(email.wordWrap),  // true
};

$email->initialize($config); 

Thank you. I see, I do need to manually initialize the email service with settings. I think I was misunderstanding the purpose of settings which cannot auto override the config. I also checked the code of Shield. They write a customized helper to override the default Email preferences.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB