forked from elkarte/Elkarte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_imap_cron.php
53 lines (45 loc) · 977 Bytes
/
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
<?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
*
* @name ElkArte Forum
* @copyright ElkArte Forum contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause
*
* @version 1.1 dev
*
*/
// Any output here is not good
error_reporting(0);
// Being run as a cron job
if (!defined('ELK'))
{
require_once(__DIR__ . '/bootstrap.php');
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()
{
global $modSettings;
// No imap, why bother?
if (!function_exists('imap_open'))
return false;
$pbe = new Pbe_Imap($modSettings);
if ($pbe !== false)
return $pbe->process();
else
return false;
}