-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_send_out_email.php
executable file
·48 lines (39 loc) · 1.41 KB
/
run_send_out_email.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
<?
# connect to mysql database
include $dir."includes/mysql.php";
include $dir."includes/aid_functions.php";
include $dir."includes/mysql_aid_functions.php";
require_once('includes/phpMailer/class.phpmailer.php');
require_once("includes/Mailer.php");
include $dir."includes/mail_aid_functions.php";
$qry = "SELECT * FROM schedule_mail_send_out WHERE status=1";
$res = query($qry);
echo "Hello: ". mysql_num_rows($res);
$msg = "EMAIL LOG SUMMARY DELIVERY INSTRUCTIONS\n";
$ct = 0;
while($item = mysql_fetch_object($res)){
$config = explode(',',$item->config);
$company = get("operator", "company", "WHERE operator_id='{$config[3]}'");
$ok = send_operator_mail($config[0],$config[1],$config[2],$config[3]);
$qry = "UPDATE schedule_mail_send_out SET status=0 WHERE oid={$item->oid}";
query($qry);
if($ok){
$msg .= "MESSAGE TO $company sent.\n";
}
else{
$msg .= "MESSAGE TO $company not sent due to faulty email address.\n";
}
$ct++;
}
if($ct>0){
$mailer = new FreakMailer();
$mailer->Subject = "EMAIL LOG SUMMARY DELIVERY INSTRUCTIONS";
$mailer->Body = $msg;
$mailer->From = "[email protected]";
$mailer->AddReplyTo('[email protected]', 'noreply');
$mailer->AddAddress("[email protected]", 'Coural Head Office');
$mailer->AddAddress("[email protected]", 'Coural Head Office');
$mailer->AddAddress("[email protected]", 'Coural Head Office');
$mailer->Send();
}
?>