/** * purpose email scheduler, this is the actual sending of all emails * params non, messages are taken from tmessage * returns nothing or failure message */ function _sendpendingmails() { global $dbi, $RZ_server, $mailhead; // M.id,S.msgstatus,M.cre_user,M.cre_date,M.mgroup_id,MG.mgroupname,M.recipient,M.msgurl,M.msgbody $ret = 0; // fetch ALL pending messages $RS = DB_listMessage($dbi, '', '', 1); // execute mailer , check if we have a group to send to or a pre-stored single recipient ... // debug($RS); foreach ($RS as $M) { if ($M[4] > 0) { $to_adr = _GetMailAdressForGroup($M[4]); } else { $to_adr = $M[6]; } // store or update the recipient list in tmessage -> recipient, else the INBOX is always empty ... $ret = mail($to_adr, 'LSDB Liga Message', $M[8] . '\\n' . 'System Link\\n' . $RZ_server . $M[7], $mailhead); if ($ret == 1) { $ret = DB_setMessageStatus($M[0], '', '', 2, $to_adr); } else { debug('Error sending mails ' . $M[8] . '\\n' . $M[7]); } } }
function _sendmail() { global $usertoken; if ($usertoken['usertype_id'] < 5) { die('Err:Msg110:WrongUser'); } $msg = strip_tags($_POST['mailmsg']); $from = strip_tags($_POST['mailfrom']); $mail_group = strip_tags($_POST['mailgrp']); $to_adr = _GetMailAdressForGroup(strip_tags($_POST['mailgrp'])); $msg_url = strip_tags($_POST['sysurl']); $msg = $msg . '\\n===== System generated email, please do not reply. ====='; if (strlen($msg_url) < 1) { $msg_url = 'lsdbMessage.php'; } #debug($from.":".$to.":".$msg); $ret = DB_setMessage($from, 6, 1, $msg, $msg_url, $mail_group, $to_adr); if (!$ret == 1) { debug('ERROR creating mail:' . $ret); return; } // abschicken ... _sendpendingmails(); }