Skip to content

Commit

Permalink
Copy some code from: PHPMailer/PHPMailer#2874
Browse files Browse the repository at this point in the history
  • Loading branch information
voronkovich committed Feb 20, 2023
1 parent 0f1169d commit 8cd7ecc
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ function mailurl_phpmailer_configure_smtp($phpmailer, $config)
function mailurl_phpmailer_configure_options($phpmailer, $options)
{
$allowedOptions = \get_object_vars($phpmailer);

unset($allowedOptions['Mailer']);
unset($allowedOptions['SMTPAuth']);
unset($allowedOptions['Username']);
unset($allowedOptions['Password']);
unset($allowedOptions['Hostname']);
unset($allowedOptions['Port']);
unset($allowedOptions['ErrorInfo']);

$allowedOptions = \array_keys($allowedOptions);

foreach ($options as $key => $value) {
Expand All @@ -106,26 +108,29 @@ function mailurl_phpmailer_configure_options($phpmailer, $options)
\sprintf(
'Unknown mail URL option: "%s". Allowed values: "%s"',
$key,
\implode('", "', $allowedOptions),
\implode('", "', $allowedOptions)
)
);
}

if ('true' === $value) {
$phpmailer->$key = true;
continue;
}

if ('false' === $value) {
$phpmailer->$key = false;
continue;
switch ($key) {
case 'AllowEmpty':
case 'SMTPAutoTLS':
case 'SMTPKeepAlive':
case 'SingleTo':
case 'UseSendmailOptions':
case 'do_verp':
case 'DKIM_copyHeaderFields':
$phpmailer->$key = (bool) $value;
break;
case 'Priority':
case 'SMTPDebug':
case 'WordWrap':
$phpmailer->$key = (integer) $value;
break;
default:
$phpmailer->$key = $value;
break;
}

if (\is_numeric($value)) {
$phpmailer->$key = (integer) $value;
continue;
}

$phpmailer->$key = $value;
}
}

0 comments on commit 8cd7ecc

Please sign in to comment.