]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Email.php
Logger Levels
[friendica.git] / src / Protocol / Email.php
index b1eeb94d62f8903023c97ae3bec2074b9e828300..bb70972b03ced7d9f11fdbe1d66131ab94b08b95 100644 (file)
@@ -4,7 +4,9 @@
  */
 namespace Friendica\Protocol;
 
-require_once 'include/html2plain.php';
+use Friendica\Core\Logger;
+use Friendica\Content\Text\HTML;
+use Friendica\Core\Protocol;
 
 /**
  * @brief Email class
@@ -25,6 +27,16 @@ class Email
 
                $mbox = @imap_open($mailbox, $username, $password);
 
+               $errors = imap_errors();
+               if (!empty($errors)) {
+                       Logger::log('IMAP Errors occured: ' . json_encode($errors));
+               }
+
+               $alerts = imap_alerts();
+               if (!empty($alerts)) {
+                       Logger::log('IMAP Alerts occured: ' . json_encode($alerts));
+               }
+
                return $mbox;
        }
 
@@ -43,21 +55,21 @@ class Email
                if (!$search1) {
                        $search1 = [];
                } else {
-                       logger("Found mails from ".$email_addr, LOGGER_DEBUG);
+                       Logger::log("Found mails from ".$email_addr, Logger::DEBUG);
                }
 
                $search2 = @imap_search($mbox, 'TO "' . $email_addr . '"', SE_UID);
                if (!$search2) {
                        $search2 = [];
                } else {
-                       logger("Found mails to ".$email_addr, LOGGER_DEBUG);
+                       Logger::log("Found mails to ".$email_addr, Logger::DEBUG);
                }
 
                $search3 = @imap_search($mbox, 'CC "' . $email_addr . '"', SE_UID);
                if (!$search3) {
                        $search3 = [];
                } else {
-                       logger("Found mails cc ".$email_addr, LOGGER_DEBUG);
+                       Logger::log("Found mails cc ".$email_addr, Logger::DEBUG);
                }
 
                $res = array_unique(array_merge($search1, $search2, $search3));
@@ -111,7 +123,7 @@ class Email
                        if (trim($ret['body']) == '') {
                                $ret['body'] = self::messageGetPart($mbox, $uid, $struc, 0, 'plain');
                        } else {
-                               $ret['body'] = html2bbcode($ret['body']);
+                               $ret['body'] = HTML::toBBCode($ret['body']);
                        }
                } else {
                        $text = '';
@@ -128,7 +140,7 @@ class Email
                                }
                        }
                        if (trim($html) != '') {
-                               $ret['body'] = html2bbcode($html);
+                               $ret['body'] = HTML::toBBCode($html);
                        } else {
                                $ret['body'] = $text;
                        }
@@ -298,7 +310,7 @@ class Email
        }
 
        /**
-        * Function send is used by NETWORK_EMAIL and NETWORK_EMAIL2 code
+        * Function send is used by Protocol::EMAIL and Protocol::EMAIL2 code
         * (not to notify the user, but to send items to email contacts)
         *
         * @param string $addr    address
@@ -328,7 +340,7 @@ class Email
                $body .= "Content-Transfer-Encoding: 8bit\n";
                $body .= "Content-Type: text/plain; charset=utf-8; format=flowed\n\n";
 
-               $body .= html2plain($html)."\n";
+               $body .= HTML::toPlaintext($html)."\n";
 
                $body .= "--=_".$part."\n";
                $body .= "Content-Transfer-Encoding: 8bit\n";
@@ -340,7 +352,7 @@ class Email
 
                //$message = '<html><body>' . $html . '</body></html>';
                //$message = html2plain($html);
-               logger('notifier: email delivery to ' . $addr);
+               Logger::log('notifier: email delivery to ' . $addr);
                mail($addr, $subject, $body, $headers);
        }