forked from elkarte/Elkarte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail_imap_cron.php
65 lines (56 loc) · 1.07 KB
/
email_imap_cron.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Should be run from a cron job to fetch messages from an imap mailbox
* Can be called from scheduled tasks (fake-cron) if needed
*
* @package ElkArte Forum
* @copyright ElkArte Forum contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
*
* @version 2.0 dev
*
*/
// Any output here is not good
use ElkArte\PbeImap;
error_reporting(0);
// Being run as a cron job
if (!defined('ELK'))
{
global $ssi_guest_access;
require_once(__DIR__ . '/bootstrap.php');
$ssi_guest_access = true;
new Bootstrap(true);
postbyemail_imap();
// Need to keep the cli clean on return
exit(0);
}
// Or a scheduled task
else
{
postbyemail_imap();
}
/**
* postbyemail_imap()
*
* Starts the posting of new messages found in the imap account
* or the .eml file
*
* Called by a scheduled task or cronjob
*/
function postbyemail_imap()
{
// No imap, why bother?
if (!function_exists('imap_open'))
{
return false;
}
$pbe = new PbeImap();
if ($pbe !== false)
{
return $pbe->process();
}
else
{
return false;
}
}