Source for file LC_Page_Admin_Mail_Sendmail.php
Documentation is available at LC_Page_Admin_Mail_Sendmail.php
* This file is part of EC-CUBE
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
* http://www.lockon.co.jp/
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once(CLASS_PATH .
"pages/LC_Page.php");
* @author LOCKON CO.,LTD.
if(file_exists(MODULE_PATH .
"mdl_speedmail/SC_SpeedMail.php")) {
require_once(MODULE_PATH .
"mdl_speedmail/SC_SpeedMail.php");
$this->objMail =
new SC_SpeedMail();
if(MELMAGA_SEND !=
true) {
if($_GET['mode'] ==
'now') {
$time_data =
$conn->getAll( "SELECT send_id FROM dtb_send_history WHERE complete_count = 0 AND del_flg = 0 AND end_date IS NULL ORDER BY send_id ASC, start_date ASC" );
// postgresql と mysql とでSQLをわける
if (DB_TYPE ==
"pgsql") {
$sql =
"SELECT send_id FROM dtb_send_history ";
$sql.=
"WHERE start_date BETWEEN current_timestamp + '- 5 minutes' AND current_timestamp + '5 minutes' AND del_flg = 0 AND end_date IS NULL ORDER BY send_id ASC, start_date ASC";
}else if (DB_TYPE ==
"mysql") {
$sql =
"SELECT send_id FROM dtb_send_history ";
$sql.=
"WHERE start_date BETWEEN date_add(now(),INTERVAL -5 minute) AND date_add(now(),INTERVAL 5 minute) AND del_flg = 0 AND end_date IS NULL ORDER BY send_id ASC, start_date ASC";
//---- 30分毎にCronが送信時間データ確認
$time_data =
$conn->getAll($sql);
$count =
count($time_data);
//未送信メルマガがあれば送信処理を続ける。なければ中断する。
print
("start sending <br />\n");
print
("not found <br />\n");
for( $i =
0; $i <
$count; $i++
) {
$sql =
"SELECT * FROM dtb_send_customer WHERE send_id = ? AND (send_flag = 2 OR send_flag IS NULL)";
$list_data[] =
$conn->getAll( $sql, array( $time_data[$i]["send_id"] ) );
$sql =
"SELECT * FROM dtb_send_history WHERE send_id = ?";
$mail_data[] =
$conn->getAll( $sql, array( $time_data[$i]["send_id"] ) );
$sql_flag =
"UPDATE dtb_send_customer SET send_flag = ? WHERE send_id = ? AND customer_id = ?";
for( $i =
0; $i <
$count; $i++
) {
for( $j =
0; $j <
count( $list_data[$i] ); $j ++
) {
$name =
trim($list_data[$i][$j]["name"]);
$subjectBody =
ereg_replace( "{name}", $customerName , $mail_data[$i][0]["subject"] );
$mailBody =
ereg_replace( "{name}", $customerName , $mail_data[$i][0]["body"] );
$list_data[$i][$j]["email"]
,$objSite->data["email03"] // 送信元メールアドレス
,$objSite->data["company_name"] // 送信元名
,$objSite->data["email03"] // reply_to
,$objSite->data["email04"] // return_path
,$objSite->data["email04"] // errors_to
if( $mail_data[$i][0]["mail_method"] ==
2 ) {
$sendResut =
$this->objMail->sendMail();
$sendResut =
$this->objMail->sendHtmlMail();
//-- 送信完了なら1、失敗なら-1をメール送信結果フラグとしてDBに挿入
$sql =
"UPDATE dtb_send_history SET complete_count = complete_count + 1 WHERE send_id = ?";
$conn->query( $sql, array($mail_data[$i][0]["send_id"]));
$conn->query( $sql_flag, array( $sendFlag, $mail_data[$i][0]["send_id"], $list_data[$i][$j]["customer_id"] ) );
$completeSql =
"UPDATE dtb_send_history SET end_date = now() WHERE send_id = ?";
$conn->query( $completeSql, array( $time_data[$i]["send_id"] ) );
$compSubject =
date("Y年m月d日H時i分" .
" 下記メールの配信が完了しました。" );
$this->objMail->setTo($objSite->data["email03"]);
$this->objMail->setSubject($compSubject);
if( $mail_data[$i][0]["mail_method"] ==
2 ) {
$sendResut =
$this->objMail->sendMail();
$sendResut =
$this->objMail->sendHtmlMail();
if ($_GET['mode'] =
"now") {
header("Location: " .
URL_DIR .
"admin/mail/history.php");
Documentation generated on Tue, 28 Apr 2009 18:11:18 +0900 by phpDocumentor 1.4.2