return false;
}
- Item::incrementInbound(Protocol::MAIL);
$mbox = @imap_open($mailbox, $username, $password);
$errors = imap_errors();
Logger::notice('IMAP Alerts occurred: ', ['alerts' => $alerts]);
}
+ if (empty($errors) && empty($alerts)) {
+ Item::incrementInbound(Protocol::MAIL);
+ }
return $mbox;
}
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));
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) {
return $ret;
}
+ Item::incrementInbound(Protocol::MAIL);
+
if (empty($struc->parts)) {
$html = trim(self::messageGetPart($mbox, $uid, $struc, 0, 'html'));
//$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;
}
/**