![]() |
How can I send an email with the default configuration (Config\Email) and immediately afterwards send a second one with another configuration (Config\Email2) and finally restore the default one?
You need to create two seperate configs for the email.
CodeIgniter 4 User Guide - Setting Email Preferences PHP Code: $email->initialize($config1); That should get you going. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(02-17-2022, 01:38 AM)InsiteFX Wrote: You need to create two seperate configs for the email. I have already created the two configuration files for it, so should I do this? PHP Code: $config1 = config('Email1'); Doing so, however, gives me this error Cannot use object of type Config\Email1 as array
Email::initialize() accepts object instance of Config\Email or array as argument. From the error it seems you are passing neither an array or Config\Email instance.
Two possible solutions: 1) Config\Email1 and Config\Email2 should extend Config\Email. So, retain the original Config\Email provided by the framework. Then, in each Email1 and Email2, class Email1 extends Email {} // instead of extends BaseConfig class Email2 extends Email {} // instead of extends BaseConfig 2) Use `get_object_vars` $email->initialize(get_object_vars($config1)); $email->initialize(get_object_vars($config2));
(02-17-2022, 08:51 PM)paulbalandan Wrote: Email::initialize() accepts object instance of Config\Email or array as argument. From the error it seems you are passing neither an array or Config\Email instance. Perfect, thanks ![]() |
Welcome Guest, Not a member yet? Register Sign In |