]> git.mxchange.org Git - friendica.git/commitdiff
Adds 'emailer_send_prepare' and 'emailer_send' hooks
authorFabio Comuni <fabrix.xm@gmail.com>
Mon, 29 Dec 2014 14:44:30 +0000 (15:44 +0100)
committerFabio Comuni <fabrix.xm@gmail.com>
Mon, 29 Dec 2014 14:44:30 +0000 (15:44 +0100)
Adds relative documentation in doc/Plugins

doc/Plugins.md
include/Emailer.php

index 2ae942eae5572bbc21df6525ca2b4bbe41ddf762..833c1d200e8f4505fe7d2e51254de047dabe4c3e 100644 (file)
@@ -196,6 +196,24 @@ Current hooks:
         'email' => email to look up the avatar for
         'url' => the (string) generated URL of the avatar
 
+**'emailer_send_prepare'** - called from Emailer::send() before building the mime message
+    $b is (array) , params to Emailer::send()
+     '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
+
+**'emailer_send'** - called before calling PHP's mail()
+    $b is (array) , params to mail()
+     'to'
+     'subject'
+     'body'
+     'headers'
+
 
 A complete list of all hook callbacks with file locations (generated 14-Feb-2012): Please see the source for details of any hooks not documented above.
 
index 535a0542893dc3b88dcceda64551264295b41ca0..f61636d959ccf72c0205ffa3534934a5e28d84e3 100644 (file)
@@ -17,6 +17,8 @@ class Emailer {
         */
        static public function send($params) {
 
+               call_hooks('emailer_send_prepare', $params);
+
                $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
                $messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
 
@@ -49,11 +51,18 @@ class Emailer {
                        "--" . $mimeBoundary . "--\n";                                  // message ending
 
                // send the message
+               $hookdata = array(
+                       'to' => $params['toEmail'],
+                       'subject' => $messageSubject,
+                       'body' => $multipartMessageBody,
+                       'headers' => $messageHeader
+               );
+               call_hooks("emailer_send", $hookdata);
                $res = mail(
-                       $params['toEmail'],                                                                             // send to address
-                       $messageSubject,                                                                // subject
-                       $multipartMessageBody,                                                  // message body
-                       $messageHeader                                                                  // message headers
+                       $hookdata['to'],                                                        // send to address
+                       $hookdata['subject'],                                           // subject
+                       $hookdata['body'],                                                      // message body
+                       $hookdata['headers'],                                           // message headers
                );
                logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG);
                logger("return value " . (($res)?"true":"false"), LOGGER_DEBUG);