fix Argument 2 passed to EGroupware\Api\Mail\Smtp::mailbox_address() must be of the type string, null given

called in /usr/share/egroupware/api/src/Mail/Smtp.php on line 238
caused by no mail domain specified in config or mail account
This commit is contained in:
ralf 2023-02-07 08:19:24 +01:00
parent eb416c3d91
commit 7522e7615f
2 changed files with 9 additions and 8 deletions

View File

@ -244,13 +244,12 @@ class Smtp
* If $account is an array (with values for keys account_(id|lid|email), it does NOT call accounts class
*
* @param int|array $account account_id or whole account array with values for keys
* @param string $domain domain
* @param string $domain|null domain
* @param string $mail_login_type=null standard(uid), vmailmgr(uid@domain), email or uidNumber
* @return string
* @return string|null null if no domain given but required by $mail_login_type
*/
static public function mailbox_address($account, string $domain, string $mail_login_type=null)
static public function mailbox_address($account, string $domain=null, string $mail_login_type=null)
{
switch($mail_login_type)
{
case 'email':
@ -258,6 +257,7 @@ class Smtp
break;
case 'uidNumber':
if (empty($domain)) return null;
if (is_array($account)) $account = $account['account_id'];
$mbox = 'u'.$account.'@'.$domain;
break;
@ -268,6 +268,7 @@ class Smtp
case 'vmailmgr':
default:
if (empty($domain)) return null;
$mbox = is_array($account) ? $account['account_lid'] : $GLOBALS['egw']->accounts->id2name($account);
$mbox .= '@'.$domain;
break;
@ -276,4 +277,4 @@ class Smtp
return $mbox;
}
}
}

View File

@ -251,9 +251,9 @@ class Ldap extends Mail\Smtp
$mailLocalAddress : static::MAIL_ENABLED;
}
// does schema support an explicit mailbox name --> set it
if (static::MAILBOX_ATTR)
if (static::MAILBOX_ATTR && !empty($mailbox = self::mailbox_addr($_hookValues)))
{
$newData[static::MAILBOX_ATTR] = self::mailbox_addr($_hookValues);
$newData[static::MAILBOX_ATTR] = $mailbox;
}
// allow extending classes to add extra data
@ -862,4 +862,4 @@ class Ldap extends Mail\Smtp
{
return Api\Ldap::factory();
}
}
}