* @return bool
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function send($params)
+ public static function send(array $params)
{
+ $params['sent'] = false;
+
Hook::callAll('emailer_send_prepare', $params);
+ if ($params['sent']) {
+ return true;
+ }
+
$email_textonly = false;
if (!empty($params['uid'])) {
- $email_textonly = PConfig::get($params['uid'], "system", "email_textonly");
+ $email_textonly = DI::pConfig()->get($params['uid'], "system", "email_textonly");
}
$fromName = Email::encodeHeader(html_entity_decode($params['fromName'], ENT_QUOTES, 'UTF-8'), 'UTF-8');
.rand(10000, 99999);
// generate a multipart/alternative message header
- $messageHeader = defaults($params, 'additionalMailHeader', '') .
+ $messageHeader = ($params['additionalMailHeader'] ?? '') .
"From: $fromName <{$params['fromEmail']}>\n" .
"Reply-To: $fromName <{$params['replyTo']}>\n" .
"MIME-Version: 1.0\n" .
'subject' => $messageSubject,
'body' => $multipartMessageBody,
'headers' => $messageHeader,
- 'parameters' => $sendmail_params
+ 'parameters' => $sendmail_params,
+ 'sent' => false,
];
Hook::callAll("emailer_send", $hookdata);
+ if ($hookdata['sent']) {
+ return true;
+ }
+
$res = mail(
$hookdata['to'],
$hookdata['subject'],