Child pages
  • [emails] Bail out early when email is sent to nobody [5.2.2-B1]
Skip to end of metadata
Go to start of metadata

When In-Portal attempts to send email to an empty email address exception with obscure message like this happens:

Exception: mail error: header To is required in .../core/kernel/utility/email_send.php on line 1131

This isn't helpful to either end user or developers who need to fix this error later.

Solution

  1. in the "kEmail::send" method after all headers were sent:
    • call "$this->sender->GetRecipientsByHeader('To')" method
    • when it returns empty recipient list throw an exception
    • exception message: "Unable to send "email-template name" email due empty recipient list."

Related Discussions

Related Tasks