<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\Content\Text\HTML;
use Friendica\Model\Item;
use Friendica\Util\Strings;
+use \IMAP\Connection;
/**
* Email class
* @param string $mailbox The mailbox name
* @param string $username The username
* @param string $password The password
- * @return resource
+ * @return Connection|resource
* @throws \Exception
*/
public static function connect($mailbox, $username, $password)
$errors = imap_errors();
if (!empty($errors)) {
- Logger::log('IMAP Errors occured: ' . json_encode($errors));
+ Logger::notice('IMAP Errors occured', ['errors' => $errors]);
}
$alerts = imap_alerts();
if (!empty($alerts)) {
- Logger::log('IMAP Alerts occured: ' . json_encode($alerts));
+ Logger::notice('IMAP Alerts occured: ', ['alerts' => $alerts]);
}
return $mbox;
}
/**
- * @param resource $mbox mailbox
- * @param string $email_addr email
+ * @param Connection|resource $mbox mailbox
+ * @param string $email_addr email
* @return array
* @throws \Exception
*/
- public static function poll($mbox, $email_addr)
+ public static function poll($mbox, $email_addr): array
{
if (!$mbox || !$email_addr) {
return [];
if (!$search1) {
$search1 = [];
} else {
- Logger::log("Found mails from ".$email_addr, Logger::DEBUG);
+ Logger::notice("Found mails from ".$email_addr);
}
$search2 = @imap_search($mbox, 'UNDELETED TO "' . $email_addr . '"', SE_UID);
if (!$search2) {
$search2 = [];
} else {
- Logger::log("Found mails to ".$email_addr, Logger::DEBUG);
+ Logger::notice("Found mails to ".$email_addr);
}
$search3 = @imap_search($mbox, 'UNDELETED CC "' . $email_addr . '"', SE_UID);
if (!$search3) {
$search3 = [];
} else {
- Logger::log("Found mails cc ".$email_addr, Logger::DEBUG);
+ Logger::notice("Found mails cc ".$email_addr);
}
$res = array_unique(array_merge($search1, $search2, $search3));
}
/**
- * @param resource $mbox mailbox
- * @param integer $uid user id
+ * @param Connection|resource $mbox mailbox
+ * @param integer $uid user id
* @return mixed
*/
public static function messageMeta($mbox, $uid)
}
/**
- * @param resource $mbox mailbox
- * @param integer $uid user id
- * @param string $reply reply
+ * @param Connection|resource $mbox mailbox
+ * @param integer $uid user id
+ * @param string $reply reply
* @return array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function getMessage($mbox, $uid, $reply, $item)
+ public static function getMessage($mbox, $uid, $reply, $item): array
{
$ret = $item;
/**
* fetch the specified message part number with the specified subtype
*
- * @param resource $mbox mailbox
- * @param integer $uid user id
- * @param object $p parts
- * @param integer $partno part number
- * @param string $subtype sub type
+ * @param Connection|resource $mbox mailbox
+ * @param integer $uid user id
+ * @param object $p parts
+ * @param integer $partno part number
+ * @param string $subtype sub type
* @return string
*/
private static function messageGetPart($mbox, $uid, $p, $partno, $subtype)
//$message = '<html><body>' . $html . '</body></html>';
//$message = html2plain($html);
- Logger::log('notifier: email delivery to ' . $addr);
+ Logger::notice('notifier: email delivery to ' . $addr);
mail($addr, $subject, $body, $headers);
}