mirror of
https://github.com/friendica/friendica
synced 2025-01-18 15:44:28 +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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item::incrementInbound(Protocol::MAIL);
|
|
||||||
$mbox = @imap_open($mailbox, $username, $password);
|
$mbox = @imap_open($mailbox, $username, $password);
|
||||||
|
|
||||||
$errors = imap_errors();
|
$errors = imap_errors();
|
||||||
|
@ -61,6 +60,9 @@ class Email
|
||||||
Logger::notice('IMAP Alerts occurred: ', ['alerts' => $alerts]);
|
Logger::notice('IMAP Alerts occurred: ', ['alerts' => $alerts]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($errors) && empty($alerts)) {
|
||||||
|
Item::incrementInbound(Protocol::MAIL);
|
||||||
|
}
|
||||||
return $mbox;
|
return $mbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,28 +78,28 @@ class Email
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
Item::incrementInbound(Protocol::MAIL);
|
|
||||||
$search1 = @imap_search($mbox, 'UNDELETED FROM "' . $email_addr . '"', SE_UID);
|
$search1 = @imap_search($mbox, 'UNDELETED FROM "' . $email_addr . '"', SE_UID);
|
||||||
if (!$search1) {
|
if (!$search1) {
|
||||||
$search1 = [];
|
$search1 = [];
|
||||||
} else {
|
} else {
|
||||||
Logger::debug("Found mails from ".$email_addr);
|
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);
|
$search2 = @imap_search($mbox, 'UNDELETED TO "' . $email_addr . '"', SE_UID);
|
||||||
if (!$search2) {
|
if (!$search2) {
|
||||||
$search2 = [];
|
$search2 = [];
|
||||||
} else {
|
} else {
|
||||||
Logger::debug("Found mails to ".$email_addr);
|
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);
|
$search3 = @imap_search($mbox, 'UNDELETED CC "' . $email_addr . '"', SE_UID);
|
||||||
if (!$search3) {
|
if (!$search3) {
|
||||||
$search3 = [];
|
$search3 = [];
|
||||||
} else {
|
} else {
|
||||||
Logger::debug("Found mails cc ".$email_addr);
|
Logger::debug("Found mails cc ".$email_addr);
|
||||||
|
Item::incrementInbound(Protocol::MAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = array_unique(array_merge($search1, $search2, $search3));
|
$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
|
public static function getMessage($mbox, int $uid, string $reply, array $item): array
|
||||||
{
|
{
|
||||||
$ret = $item;
|
$ret = $item;
|
||||||
Item::incrementInbound(Protocol::MAIL);
|
|
||||||
$struc = (($mbox && $uid) ? @imap_fetchstructure($mbox, $uid, FT_UID) : null);
|
$struc = (($mbox && $uid) ? @imap_fetchstructure($mbox, $uid, FT_UID) : null);
|
||||||
|
|
||||||
if (!$struc) {
|
if (!$struc) {
|
||||||
|
@ -149,6 +150,8 @@ class Email
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item::incrementInbound(Protocol::MAIL);
|
||||||
|
|
||||||
if (empty($struc->parts)) {
|
if (empty($struc->parts)) {
|
||||||
$html = trim(self::messageGetPart($mbox, $uid, $struc, 0, 'html'));
|
$html = trim(self::messageGetPart($mbox, $uid, $struc, 0, 'html'));
|
||||||
|
|
||||||
|
@ -408,8 +411,11 @@ class Email
|
||||||
//$message = '<html><body>' . $html . '</body></html>';
|
//$message = '<html><body>' . $html . '</body></html>';
|
||||||
//$message = html2plain($html);
|
//$message = html2plain($html);
|
||||||
Logger::notice('notifier: email delivery to ' . $addr);
|
Logger::notice('notifier: email delivery to ' . $addr);
|
||||||
|
$success = mail($addr, $subject, $body, $headers);
|
||||||
|
if ($success) {
|
||||||
Item::incrementOutbound(Protocol::MAIL);
|
Item::incrementOutbound(Protocol::MAIL);
|
||||||
return mail($addr, $subject, $body, $headers);
|
}
|
||||||
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue