diff --git a/src/Util/EMailer/MailBuilder.php b/src/Util/EMailer/MailBuilder.php index fe801bd562..c2c2f75dc5 100644 --- a/src/Util/EMailer/MailBuilder.php +++ b/src/Util/EMailer/MailBuilder.php @@ -140,14 +140,17 @@ abstract class MailBuilder { if ((empty($this->recipientAddress)) && !empty($this->recipientUid)) { - $user = User::getById($this->recipientUid, ['username', 'email']); + $user = User::getById($this->recipientUid, ['email']); if (!empty($user)) { - $this->senderName = $user['username']; - $this->senderAddress = $user['email']; + $this->recipientAddress = $user['email']; } } + if (empty($this->recipientAddress)) { + throw new InternalServerErrorException('Recipient address is missing.'); + } + if (empty($this->senderAddress) || empty($this->senderName)) { throw new InternalServerErrorException('Sender address or name is missing.'); }