mirror of
https://github.com/friendica/friendica
synced 2024-11-09 16:22:56 +00:00
Increment inbound/outbound on mails per result
This commit is contained in:
parent
80bd572393
commit
f47c4c3dd6
1 changed files with 13 additions and 7 deletions
|
@ -48,7 +48,6 @@ class Email
|
|||
return false;
|
||||
}
|
||||
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
$mbox = @imap_open($mailbox, $username, $password);
|
||||
|
||||
$errors = imap_errors();
|
||||
|
@ -61,6 +60,9 @@ class Email
|
|||
Logger::notice('IMAP Alerts occurred: ', ['alerts' => $alerts]);
|
||||
}
|
||||
|
||||
if (empty($errors) && empty($alerts)) {
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
}
|
||||
return $mbox;
|
||||
}
|
||||
|
||||
|
@ -76,28 +78,28 @@ class Email
|
|||
return [];
|
||||
}
|
||||
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
$search1 = @imap_search($mbox, 'UNDELETED FROM "' . $email_addr . '"', SE_UID);
|
||||
if (!$search1) {
|
||||
$search1 = [];
|
||||
} else {
|
||||
Logger::debug("Found mails from ".$email_addr);
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
}
|
||||
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
$search2 = @imap_search($mbox, 'UNDELETED TO "' . $email_addr . '"', SE_UID);
|
||||
if (!$search2) {
|
||||
$search2 = [];
|
||||
} else {
|
||||
Logger::debug("Found mails to ".$email_addr);
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
}
|
||||
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
$search3 = @imap_search($mbox, 'UNDELETED CC "' . $email_addr . '"', SE_UID);
|
||||
if (!$search3) {
|
||||
$search3 = [];
|
||||
} else {
|
||||
Logger::debug("Found mails cc ".$email_addr);
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
}
|
||||
|
||||
$res = array_unique(array_merge($search1, $search2, $search3));
|
||||
|
@ -141,7 +143,6 @@ class Email
|
|||
public static function getMessage($mbox, int $uid, string $reply, array $item): array
|
||||
{
|
||||
$ret = $item;
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
$struc = (($mbox && $uid) ? @imap_fetchstructure($mbox, $uid, FT_UID) : null);
|
||||
|
||||
if (!$struc) {
|
||||
|
@ -149,6 +150,8 @@ class Email
|
|||
return $ret;
|
||||
}
|
||||
|
||||
Item::incrementInbound(Protocol::MAIL);
|
||||
|
||||
if (empty($struc->parts)) {
|
||||
$html = trim(self::messageGetPart($mbox, $uid, $struc, 0, 'html'));
|
||||
|
||||
|
@ -408,8 +411,11 @@ class Email
|
|||
//$message = '<html><body>' . $html . '</body></html>';
|
||||
//$message = html2plain($html);
|
||||
Logger::notice('notifier: email delivery to ' . $addr);
|
||||
Item::incrementOutbound(Protocol::MAIL);
|
||||
return mail($addr, $subject, $body, $headers);
|
||||
$success = mail($addr, $subject, $body, $headers);
|
||||
if ($success) {
|
||||
Item::incrementOutbound(Protocol::MAIL);
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue