48 lines
1.2 KiB
PHP
Executable File
48 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace DT\ImapMailMerge\Main;
|
|
|
|
class ProcessInbox
|
|
{
|
|
|
|
private $config;
|
|
public $imap;
|
|
public $folders;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->config = parse_ini_file( dirname(dirname(dirname(__FILE__))) . "/config/config.ini", true);
|
|
$this->imap = new \DT\ImapMailMerge\Imap\Connection;
|
|
$this->folders = new \DT\ImapMailMerge\Imap\Folders;
|
|
|
|
$this->imapProcessInbox();
|
|
|
|
}
|
|
|
|
public function imapProcessInbox()
|
|
{
|
|
|
|
$this->folders->imapDir('INBOX');
|
|
|
|
$mbox_pre = $this->imap;
|
|
$mbox = $mbox_pre::$imapConn;
|
|
|
|
$numMessages = imap_num_msg($mbox);
|
|
|
|
for ($i = $numMessages; $i > 0; $i--) {
|
|
$msgId = imap_uid($mbox, $i);
|
|
$header = (imap_header($mbox, $i)) ? imap_header($mbox, $i) : "";
|
|
$account = (isset($header->from[0])) ? $header->from[0] : "";
|
|
$accountSlug = strtolower($account->mailbox);
|
|
|
|
if (in_array($accountSlug, $this->config['safelist'])) {
|
|
imap_mail_move($mbox, $msgId, 'INBOX.' . $accountSlug, CP_UID);
|
|
imap_expunge($mbox);
|
|
}
|
|
|
|
}
|
|
|
|
imap_expunge($mbox);
|
|
|
|
}
|
|
} |