-
Notifications
You must be signed in to change notification settings - Fork 1
/
mailqueue.php
executable file
·59 lines (56 loc) · 1.84 KB
/
mailqueue.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
<?php
if (php_sapi_name() != 'cli') { exit('error'); }
global $mailqueue;
$mailqueue = true;
require_once('config.php');
require_once('db.php');
require_once('mail.php');
$work = 0;
$db = new db($dbLang, $dbName);
for ($i = 0; $i < 1; $i++)
{
$results = $db->query("SELECT * FROM mail_queue ORDER BY mid ASC LIMIT 10;");
foreach ($results as $result)
{
$work = 1;
$id = intval($result['mid']);
$to = base64_decode($result['mto']);
$subject = base64_decode($result['msubject']);
$headers = base64_decode($result['mheaders']);
$body = base64_decode($result['mbody']);
$db->query("DELETE FROM mail_queue WHERE mid = $id");
mail($to,$subject,$body,$headers);
}
}
$db->close();
$dbUser = $db2User;
$dbPass = $db2Pass;
$db = new db($db2Lang, $db2Name);
for ($i = 0; $i < 1; $i++)
{
$results = $db->query("SELECT * FROM adm_mail_queue ORDER BY mid ASC LIMIT 10;");
foreach ($results as $result)
{
$work = 1;
$id = intval($result['mid']);
$to = base64_decode($result['mto']);
$subject = base64_decode($result['msubject']);
$headers = null;
if ($result['mheaders'] != '')
$headers = base64_decode($result['mheaders']);
$body = base64_decode($result['mbody']);
$params = null;
if ($result['mparams'] != '')
$params = base64_decode($result['mparams']);
$db->query("DELETE FROM adm_mail_queue WHERE mid = $id");
if ($headers == null)
mail($to,$subject,$body);
else if ($params == null)
mail($to,$subject,$body,$headers);
else
mail($to,$subject,$body,$headers,$params);
}
}
$db->close();
if ($work == 1)
echo "OK\n";