X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FUtil%2FEmailer.php;h=4310046c234411b1f6fd6907f8613a4075ebc7c3;hb=77610179156eeadcb22ee3735574a3b07935439a;hp=42aab8f5f3ef625409d199d291c05a1e64986bb9;hpb=2f28c2ebbfd8f66093d7081d40b1d48f65fcff20;p=friendica.git diff --git a/src/Util/Emailer.php b/src/Util/Emailer.php index 42aab8f5f3..4310046c23 100644 --- a/src/Util/Emailer.php +++ b/src/Util/Emailer.php @@ -4,8 +4,8 @@ */ namespace Friendica\Util; -use Friendica\Core\Addon; use Friendica\Core\Config; +use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\PConfig; use Friendica\Protocol\Email; @@ -19,24 +19,31 @@ class Emailer * Send a multipart/alternative message with Text and HTML versions * * @param array $params parameters - * fromName name of the sender - * fromEmail email fo the sender - * replyTo replyTo address to direct responses - * toEmail destination email address - * messageSubject subject of the message - * htmlVersion html version of the message - * textVersion text only version of the message - * additionalMailHeader additions to the smtp mail header + * fromName name of the sender + * fromEmail email of the sender + * replyTo address to direct responses + * toEmail destination email address + * messageSubject subject of the message + * htmlVersion html version of the message + * textVersion text only version of the message + * additionalMailHeader additions to the SMTP mail header * optional uid user id of the destination user * - * @return object + * @return bool + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function send($params) + public static function send(array $params) { - Addon::callHooks('emailer_send_prepare', $params); + $params['sent'] = false; + + Hook::callAll('emailer_send_prepare', $params); + + if ($params['sent']) { + return true; + } $email_textonly = false; - if (x($params, "uid")) { + if (!empty($params['uid'])) { $email_textonly = PConfig::get($params['uid'], "system", "email_textonly"); } @@ -86,10 +93,16 @@ class Emailer 'subject' => $messageSubject, 'body' => $multipartMessageBody, 'headers' => $messageHeader, - 'parameters' => $sendmail_params + 'parameters' => $sendmail_params, + 'sent' => false, ]; - //echo "
"; var_dump($hookdata); killme();
-		Addon::callHooks("emailer_send", $hookdata);
+
+		Hook::callAll("emailer_send", $hookdata);
+
+		if ($hookdata['sent']) {
+			return true;
+		}
+
 		$res = mail(
 			$hookdata['to'],
 			$hookdata['subject'],