-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$Email->initialize($config) not work! #1042
Comments
initialise() does not support arrays although it says in the documentation @35598253 you can use initialse() with an instance of \Config\Email :
|
since parameter docblock uses use Config\Email as ConfigEmail;
// ...
/**
* Initialize preferences
*
* @param ConfigEmail|array $config
*
* @return Email
*/
public function initialize($config)
{
$this->clear();
if (is_array($config)) {
// uses cast
$config = (object) $config;
// or create a \Config\Email instance with its properties
$configEmail = new ConfigEmail();
foreach ($config as $key => $value) {
$configEmail->$key = $value;
}
$config = $configEmail;
}
// ...
} |
You guys are correct. It should support either an array or a Config\Email instance. I think @samsonasik solution is fine. Anyone want to submit a PR? |
@lonnieezell I've created PR #1046 for it. |
Dang - you beat me to it. I just did another fix for it that is a little more elegant. Will be up shortly. |
https://bcit-ci.github.io/CodeIgniter4/libraries/email.html
Setting Email Preferences
$email = \Config\Services::email();
$config['protocol'] = 'sendmail';
$config['mailPath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordWrap'] = true;
$email->initialize($config);
OR
$email = new \CodeIgniter\Email\Email($config);
print_r($email);
the email config not change
The text was updated successfully, but these errors were encountered: