Enable addon using emailer hooks to skip default call to mail()
This commit is contained in:
parent
f225752f8a
commit
4e207ef786
|
@ -358,6 +358,7 @@ Called from `Emailer::send()` before building the mime message.
|
||||||
- **htmlVersion**: html version of the message
|
- **htmlVersion**: html version of the message
|
||||||
- **textVersion**: text only version of the message
|
- **textVersion**: text only version of the message
|
||||||
- **additionalMailHeader**: additions to the smtp mail header
|
- **additionalMailHeader**: additions to the smtp mail header
|
||||||
|
- **sent**: default false, if set to true in the hook, the default mailer will be skipped.
|
||||||
|
|
||||||
### emailer_send
|
### emailer_send
|
||||||
Called before calling PHP's `mail()`.
|
Called before calling PHP's `mail()`.
|
||||||
|
@ -367,6 +368,7 @@ Called before calling PHP's `mail()`.
|
||||||
- **subject**
|
- **subject**
|
||||||
- **body**
|
- **body**
|
||||||
- **headers**
|
- **headers**
|
||||||
|
- **sent**: default false, if set to true in the hook, the default mailer will be skipped.
|
||||||
|
|
||||||
### load_config
|
### load_config
|
||||||
Called during `App` initialization to allow addons to load their own configuration file(s) with `App::loadConfigFile()`.
|
Called during `App` initialization to allow addons to load their own configuration file(s) with `App::loadConfigFile()`.
|
||||||
|
|
|
@ -32,10 +32,16 @@ class Emailer
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @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);
|
Hook::callAll('emailer_send_prepare', $params);
|
||||||
|
|
||||||
|
if ($params['sent']) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$email_textonly = false;
|
$email_textonly = false;
|
||||||
if (!empty($params['uid'])) {
|
if (!empty($params['uid'])) {
|
||||||
$email_textonly = PConfig::get($params['uid'], "system", "email_textonly");
|
$email_textonly = PConfig::get($params['uid'], "system", "email_textonly");
|
||||||
|
@ -87,11 +93,16 @@ class Emailer
|
||||||
'subject' => $messageSubject,
|
'subject' => $messageSubject,
|
||||||
'body' => $multipartMessageBody,
|
'body' => $multipartMessageBody,
|
||||||
'headers' => $messageHeader,
|
'headers' => $messageHeader,
|
||||||
'parameters' => $sendmail_params
|
'parameters' => $sendmail_params,
|
||||||
|
'sent' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
Hook::callAll("emailer_send", $hookdata);
|
Hook::callAll("emailer_send", $hookdata);
|
||||||
|
|
||||||
|
if ($hookdata['sent']) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$res = mail(
|
$res = mail(
|
||||||
$hookdata['to'],
|
$hookdata['to'],
|
||||||
$hookdata['subject'],
|
$hookdata['subject'],
|
||||||
|
|
Loading…
Reference in a new issue