function EcmsToSendMail($email, $title, $text) { global $empire, $dbtbpre; $pr = $empire->fetch1("select sendmailtype,smtphost,fromemail,loginemail,emailusername,emailpassword,smtpport,emailname from {$dbtbpre}enewspublic limit 1"); //发送初使化 $mailer = FirstSendMail($pr, $title, $text); if (is_array($email)) { $count = count($email); for ($i = 0; $i < $count; $i++) { if ($email[$i]) { $mailer->AddAddress($email[$i]); } } } else { $mailer->AddAddress($email); } if (!$mailer->Send()) { return false; } return true; }
function DoSendMsg($add, $ecms = 0, $userid, $username) { global $empire, $dbtbpre, $user_userid, $user_username, $user_havemsg, $user_group, $user_tablename, $user_groupid, $user_email; $start = (int) $add['start']; $line = (int) $add['line']; $title = $add['title']; $msgtext = $add['msgtext']; if (empty($title) || empty($msgtext)) { printerror("EmptySendMsg", "history.go(-1)"); } if ($ecms == 1) { $enews = "SendEmail"; $mess = "SendEmailSuccess"; $returnurl = "SendEmail.php"; $pr = $empire->fetch1("select sendmailtype,smtphost,fromemail,loginemail,emailusername,emailpassword,smtpport,emailname from {$dbtbpre}enewspublic limit 1"); //发送初使化 $mailer = FirstSendMail($pr, $title, $msgtext); } else { $enews = "SendMsg"; $mess = "SendMsgSuccess"; $returnurl = "SendMsg.php"; } //会员组 $gr = ReturnSendMemberGroup($add['groupid']); $a = " and " . $gr[0]; $b = 0; $msgtime = date("Y-m-d H:i:s"); $sql = $empire->query("select " . $user_userid . "," . $user_username . "," . $user_havemsg . "," . $user_group . "," . $user_email . " from " . $user_tablename . " where " . $user_userid . ">{$start}" . $a . " order by " . $user_userid . " limit " . $line); while ($r = $empire->fetch($sql)) { $b = 1; $newstart = $r[$user_userid]; if ($ecms == 1) { $mailer->AddAddress($r[$user_email]); } else { $r[$user_username] = doUtfAndGbk($r[$user_username], 1); //编码转换 $ititle = str_replace("[!--username--]", $r[$user_username], $title); $imsgtext = str_replace("[!--username--]", $r[$user_username], $msgtext); SendSiteMsg($ititle, $imsgtext, $msgtime, $r[$user_userid], $r[$user_username], $r[$user_havemsg]); } } if (empty($b)) { //操作日志 insert_dolog("title={$title}"); printerror($mess, $returnurl); } if ($ecms == 1) { if (!$mailer->Send()) { echo $mailer->ErrorInfo; } } //输出下一组提交表单 EchoSendMsgForm($enews, $returnurl, $newstart, $line, $gr[1], $add); }