67 lines
1.9 KiB
PHP
Executable File
67 lines
1.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace DT\ImapMailMerge\Main;
|
|
|
|
/**
|
|
* Testing DocBlock
|
|
* @var [private] $config
|
|
* @var [private] $sender
|
|
* @var [public] $imap
|
|
*/
|
|
class ProcessSafelist
|
|
{
|
|
|
|
private $config;
|
|
private $sender;
|
|
public $imap;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->config = parse_ini_file( dirname(dirname(dirname(__FILE__))) . "/config/config.ini", true);
|
|
$this->sender = new \DT\ImapMailMerge\Imap\Sender;
|
|
$this->imap = new \DT\ImapMailMerge\Imap\Connection;
|
|
$this->imapProcessSafelist();
|
|
|
|
}
|
|
|
|
/**
|
|
* [imapProcessSafelist description]
|
|
* @return [type] [description]
|
|
*/
|
|
public function imapProcessSafelist()
|
|
{
|
|
|
|
$mbox_pre = $this->imap;
|
|
$mbox = $mbox_pre::$imapConn;
|
|
|
|
$dirs = imap_list($mbox, $this->config['imapServer'], "*");
|
|
|
|
for ($i = count($this->config['safelist']); $i > 0; $i--) {
|
|
$accountSlug = $this->config['safelist'][$i-1];
|
|
|
|
$accountDir = $this->config['imapServer'].'INBOX.'.$accountSlug;
|
|
$accountError = $this->config['imapServer'].'INBOX.'.$accountSlug.'.error';
|
|
$accountSuccess = $this->config['imapServer'].'INBOX.'.$accountSlug.'.success';
|
|
$accountFail = $this->config['imapServer'].'INBOX.'.$accountSlug.'.fail';
|
|
|
|
$accountDirs = array($accountDir, $accountError, $accountSuccess, $accountFail);
|
|
|
|
foreach ($accountDirs as $dir) {
|
|
if (array_search($dir, $dirs) === false) {
|
|
if (! imap_createmailbox($mbox, $dir)) {
|
|
$this->sender->imapEmailLog(
|
|
$this->config['adminEmail'],
|
|
"IMAPMailMerge: Process SafeList Errored!",
|
|
"Issue with the imap directories."
|
|
);
|
|
} else {
|
|
imap_subscribe($mbox, $dir);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |