- Timestamp:
- 2007/10/19 11:48:06 (16 years ago)
- Location:
- branches/feature-module-update
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/data/class/SC_SendMail.php
r16330 r16503 5 5 * http://www.lockon.co.jp/ 6 6 */ 7 7 8 8 require_once(dirname(__FILE__) . '/../module/Mail/Mail.php'); 9 9 require_once(dirname(__FILE__) . '/../module/Mail/mime.php'); … … 12 12 class SC_SendMail { 13 13 14 var $to; // 送信先 15 var $subject; // 題名 16 var $body; // 本文 17 var $cc; // CC 18 var $bcc; // BCC 19 var $replay_to; // replay_to 20 var $return_path; // return_path 21 var $arrEncode; 22 var $objMailMime; 23 var $arrTEXTEncode; 24 var $arrHTMLEncode; 25 var $objMail; 26 27 // コンストラクタ 28 function SC_SendMail() { 29 $this->to = ""; 30 $this->subject = ""; 31 $this->body = ""; 32 $this->cc = ""; 33 $this->bcc = ""; 34 $this->replay_to = ""; 35 $this->return_path = ""; 36 $this->arrEncode = array(); 37 $this->host = SMTP_HOST; 38 $this->port = SMTP_PORT; 39 $this->objMailMime = new Mail_mime(); 40 mb_language( "Japanese" ); 41 $arrHost = array( 14 var $to; // 送信先 15 var $subject; // 題名 16 var $body; // 本文 17 var $cc; // CC 18 var $bcc; // BCC 19 var $replay_to; // replay_to 20 var $return_path; // return_path 21 var $arrEncode; 22 var $objMailMime; 23 var $arrTEXTEncode; 24 var $arrHTMLEncode; 25 var $objMail; 26 27 // コンストラクタ 28 function SC_SendMail() { 29 $this->to = ""; 30 $this->subject = ""; 31 $this->body = ""; 32 $this->cc = ""; 33 $this->bcc = ""; 34 $this->replay_to = ""; 35 $this->return_path = ""; 36 $this->arrEncode = array(); 37 $this->backend = MAIL_BACKEND; 38 $this->host = SMTP_HOST; 39 $this->port = SMTP_PORT; 40 $this->objMailMime = new Mail_mime(); 41 mb_language( "Japanese" ); 42 43 //-- PEAR::Mailを使ってメール送信オブジェクト作成 44 $this->objMail =& Mail::factory($this->backend, 45 $this->getBackendParams($this->backend)); 46 } 47 48 // 宛先の設定 49 function setTo($to, $to_name = "") { 50 $this->to = $this->getNameAddress($to_name, $to); 51 } 52 53 // 送信元の設定 54 function setFrom($from, $from_name = "") { 55 $this->from = $this->getNameAddress($from_name, $from); 56 } 57 58 // CCの設定 59 function setCc($cc, $cc_name = "") { 60 if($cc != "") { 61 $this->cc = $this->getNameAddress($cc_name, $cc); 62 } 63 } 64 65 // BCCの設定 66 function setBCc($bcc) { 67 if($bcc != "") { 68 $this->bcc = $bcc; 69 } 70 } 71 72 // Reply-Toの設定 73 function setReplyTo($reply_to) { 74 if($reply_to != "") { 75 $this->reply_to = $reply_to; 76 } 77 } 78 79 // Return-Pathの設定 80 function setReturnPath($return_path) { 81 $this->return_path = $return_path; 82 } 83 84 // 件名の設定 85 function setSubject($subject) { 86 $this->subject = mb_encode_mimeheader($subject); 87 } 88 89 // 本文の設定 90 function setBody($body) { 91 $this->body = mb_convert_encoding($body, "JIS", CHAR_CODE); 92 } 93 94 // SMTPサーバの設定 95 function setHost($host) { 96 $this->host = $host; 97 $arrHost = array( 42 98 'host' => $this->host, 43 99 'port' => $this->port … … 45 101 //-- PEAR::Mailを使ってメール送信オブジェクト作成 46 102 $this->objMail =& Mail::factory("smtp", $arrHost); 47 } 48 49 // 宛先の設定 50 function setTo($to, $to_name = "") { 51 $this->to = $this->getNameAddress($to_name, $to); 52 } 53 54 // 送信元の設定 55 function setFrom($from, $from_name = "") { 56 $this->from = $this->getNameAddress($from_name, $from); 57 } 58 59 // CCの設定 60 function setCc($cc, $cc_name = "") { 61 if($cc != "") { 62 $this->cc = $this->getNameAddress($cc_name, $cc); 63 } 64 } 65 66 // BCCの設定 67 function setBCc($bcc) { 68 if($bcc != "") { 69 $this->bcc = $bcc; 70 } 71 } 72 73 // Reply-Toの設定 74 function setReplyTo($reply_to) { 75 if($reply_to != "") { 76 $this->reply_to = $reply_to; 77 } 78 } 79 80 // Return-Pathの設定 81 function setReturnPath($return_path) { 82 $this->return_path = $return_path; 83 } 84 85 // 件名の設定 86 function setSubject($subject) { 87 $this->subject = mb_encode_mimeheader($subject); 88 } 89 90 // 本文の設定 91 function setBody($body) { 92 $this->body = mb_convert_encoding($body, "JIS", CHAR_CODE); 93 } 94 95 // SMTPサーバの設定 96 function setHost($host) { 97 $this->host = $host; 98 $arrHost = array( 103 104 } 105 106 // SMTPポートの設定 107 function setPort($port) { 108 $this->port = $port; 109 $arrHost = array( 99 110 'host' => $this->host, 100 111 'port' => $this->port … … 102 113 //-- PEAR::Mailを使ってメール送信オブジェクト作成 103 114 $this->objMail =& Mail::factory("smtp", $arrHost); 104 105 } 106 107 // SMTPポートの設定 108 function setPort($port) { 109 $this->port = $port; 110 $arrHost = array( 111 'host' => $this->host, 112 'port' => $this->port 113 ); 114 //-- PEAR::Mailを使ってメール送信オブジェクト作成 115 $this->objMail =& Mail::factory("smtp", $arrHost); 116 } 117 118 // 名前<メールアドレス>の形式を生成 119 function getNameAddress($name, $mail_address) { 120 if($name != "") { 121 // 制御文字を変換する。 122 $_name = $name; 123 $_name = ereg_replace("<","<", $_name); 124 $_name = ereg_replace(">",">", $_name); 125 if(OS_TYPE != 'WIN') { 126 // windowsでは文字化けするので使用しない。 127 $_name = mb_convert_encoding($_name,"JIS",CHAR_CODE); 128 } 129 $_name = mb_encode_mimeheader($_name); 130 $name_address = "\"". $_name . "\"<" . $mail_address . ">"; 131 } else { 132 $name_address = $mail_address; 133 } 134 return $name_address; 135 } 136 137 function setItem( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 138 $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); 139 } 140 141 function setItemHtml( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 142 $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); 143 } 144 145 /* ヘッダ等を格納 146 $to -> 送信先メールアドレス 147 $subject -> メールのタイトル 148 $body -> メール本文 149 $fromaddress -> 送信元のメールアドレス 150 $header -> ヘッダー 151 $from_name -> 送信元の名前(全角OK) 152 $reply_to -> reply_to設定 153 $return_path -> return-pathアドレス設定(エラーメール返送用) 154 $cc -> カーボンコピー 155 $bcc -> ブラインドカーボンコピー 156 */ 157 function setBase( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 158 // 宛先設定 159 $this->to = $to; 160 // 件名設定 161 $this->setSubject($subject); 162 // 本文設定(iso-2022-jpだと特殊文字が?で送信されるのでJISを使用する) 163 $this->setBody($body); 164 // 送信元設定 165 $this->setFrom($fromaddress, $from_name); 166 // 返信先設定 167 $this->setReplyTo($reply_to); 168 // CC設定 169 $this->setCc($cc); 170 // BCC設定 171 $this->setBcc($bcc); 172 173 // Errors-Toは、ほとんどのSMTPで無視され、Return-Pathが優先されるためReturn_Pathに設定する。 174 if($errors_to != "") { 175 $this->return_path = $errors_to; 176 } else if($return_path != "") { 177 $this->return_path = $return_path; 178 } else { 179 $this->return_path = $fromaddress; 180 } 181 } 182 183 // ヘッダーを返す 184 function getBaseHeader() { 185 //-- 送信するメールの内容と送信先 186 $arrHeader['MIME-Version'] = '1.0'; 187 $arrHeader['To'] = $this->to; 188 $arrHeader['Subject'] = $this->subject; 189 $arrHeader['From'] = $this->from; 190 $arrHeader['Return-Path'] = $this->return_path; 191 192 if($this->reply_to != "") { 193 $arrHeader['Reply-To'] = $this->reply_to; 194 } 195 196 if($this->cc != "") { 197 $arrHeader['Cc'] = $this->cc; 198 } 199 200 if($this->bcc != "") { 201 $arrHeader['Bcc'] = $this->bcc; 202 } 203 return $arrHeader; 204 } 205 206 // ヘッダーを返す 207 function getTEXTHeader() { 208 $arrHeader = $this->getBaseHeader(); 209 $arrHeader['Content-Type'] = "text/plain; charset=\"ISO-2022-JP\""; 210 $arrHeader['Content-Transfer-Encoding'] = "7bit"; 211 return $arrHeader; 212 } 213 214 // ヘッダーを返す 215 function getHTMLHeader() { 216 $arrHeader = $this->getBaseHeader(); 217 $arrHeader['Content-Type'] = "text/html; charset=\"ISO-2022-JP\""; 218 $arrHeader['Content-Transfer-Encoding'] = "ISO-2022-JP"; 219 return $arrHeader; 220 } 221 222 // TXTメール送信を実行する 223 function sendMail() { 224 $header = $this->getTEXTHeader(); 115 } 116 117 // 名前<メールアドレス>の形式を生成 118 function getNameAddress($name, $mail_address) { 119 if($name != "") { 120 // 制御文字を変換する。 121 $_name = $name; 122 $_name = ereg_replace("<","<", $_name); 123 $_name = ereg_replace(">",">", $_name); 124 if(OS_TYPE != 'WIN') { 125 // windowsでは文字化けするので使用しない。 126 $_name = mb_convert_encoding($_name,"JIS",CHAR_CODE); 127 } 128 $_name = mb_encode_mimeheader($_name); 129 $name_address = "\"". $_name . "\"<" . $mail_address . ">"; 130 } else { 131 $name_address = $mail_address; 132 } 133 return $name_address; 134 } 135 136 function setItem( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 137 $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); 138 } 139 140 function setItemHtml( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 141 $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); 142 } 143 144 /* ヘッダ等を格納 145 $to -> 送信先メールアドレス 146 $subject -> メールのタイトル 147 $body -> メール本文 148 $fromaddress -> 送信元のメールアドレス 149 $header -> ヘッダー 150 $from_name -> 送信元の名前(全角OK) 151 $reply_to -> reply_to設定 152 $return_path -> return-pathアドレス設定(エラーメール返送用) 153 $cc -> カーボンコピー 154 $bcc -> ブラインドカーボンコピー 155 */ 156 function setBase( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 157 // 宛先設定 158 $this->to = $to; 159 // 件名設定 160 $this->setSubject($subject); 161 // 本文設定(iso-2022-jpだと特殊文字が?で送信されるのでJISを使用する) 162 $this->setBody($body); 163 // 送信元設定 164 $this->setFrom($fromaddress, $from_name); 165 // 返信先設定 166 $this->setReplyTo($reply_to); 167 // CC設定 168 $this->setCc($cc); 169 // BCC設定 170 $this->setBcc($bcc); 171 172 // Errors-Toは、ほとんどのSMTPで無視され、Return-Pathが優先されるためReturn_Pathに設定する。 173 if($errors_to != "") { 174 $this->return_path = $errors_to; 175 } else if($return_path != "") { 176 $this->return_path = $return_path; 177 } else { 178 $this->return_path = $fromaddress; 179 } 180 } 181 182 // ヘッダーを返す 183 function getBaseHeader() { 184 //-- 送信するメールの内容と送信先 185 $arrHeader['MIME-Version'] = '1.0'; 186 $arrHeader['To'] = $this->to; 187 $arrHeader['Subject'] = $this->subject; 188 $arrHeader['From'] = $this->from; 189 $arrHeader['Return-Path'] = $this->return_path; 190 191 if($this->reply_to != "") { 192 $arrHeader['Reply-To'] = $this->reply_to; 193 } 194 195 if($this->cc != "") { 196 $arrHeader['Cc'] = $this->cc; 197 } 198 199 if($this->bcc != "") { 200 $arrHeader['Bcc'] = $this->bcc; 201 } 202 return $arrHeader; 203 } 204 205 // ヘッダーを返す 206 function getTEXTHeader() { 207 $arrHeader = $this->getBaseHeader(); 208 $arrHeader['Content-Type'] = "text/plain; charset=\"ISO-2022-JP\""; 209 $arrHeader['Content-Transfer-Encoding'] = "7bit"; 210 return $arrHeader; 211 } 212 213 // ヘッダーを返す 214 function getHTMLHeader() { 215 $arrHeader = $this->getBaseHeader(); 216 $arrHeader['Content-Type'] = "text/html; charset=\"ISO-2022-JP\""; 217 $arrHeader['Content-Transfer-Encoding'] = "ISO-2022-JP"; 218 return $arrHeader; 219 } 220 221 // TXTメール送信を実行する 222 function sendMail() { 223 $header = $this->getTEXTHeader(); 225 224 // メール送信 226 $result = $this->objMail->send($this->to, $header, $this->body); 227 if (PEAR::isError($result)) { 228 229 230 return false; 231 232 233 234 235 236 237 225 $result = $this->objMail->send($this->to, $header, $this->body); 226 if (PEAR::isError($result)) { 227 GC_Utils_Ex::gfPrintLog($result->getMessage()); 228 GC_Utils_Ex::gfDebugLog($header); 229 return false; 230 } 231 return true; 232 } 233 234 // HTMLメール送信を実行する 235 function sendHtmlMail() { 236 $header = $this->getHTMLHeader(); 238 237 // メール送信 239 $result = $this->objMail->send($this->to, $header, $this->body); 240 if (PEAR::isError($result)) { 241 GC_Utils_Ex::gfPrintLog($result->getMessage()); 242 GC_Utils_Ex::gfDebugLog($header); 243 return false; 244 } 245 return true; 246 } 238 $result = $this->objMail->send($this->to, $header, $this->body); 239 if (PEAR::isError($result)) { 240 GC_Utils_Ex::gfPrintLog($result->getMessage()); 241 GC_Utils_Ex::gfDebugLog($header); 242 return false; 243 } 244 return true; 245 } 246 247 /** 248 * メーラーバックエンドに応じたパラメータを返す. 249 * 250 * @param string $backend Pear::Mail のバックエンド 251 * @return array メーラーバックエンドに応じたパラメータの配列 252 */ 253 function getBackendParams($backend) { 254 255 switch ($backend) { 256 case "mail": 257 return array(); 258 break; 259 260 case "sendmail": 261 $arrParams = array('sendmail_path' => '/usr/bin/sendmail', 262 'sendmail_args' => '-i' 263 ); 264 break; 265 266 case "smtp": 267 default: 268 $arrParams = array( 269 'host' => $this->host, 270 'port' => $this->port 271 ); 272 } 273 } 247 274 } 248 275 ?> -
branches/feature-module-update/data/class/helper/SC_Helper_Mail.php
r16322 r16503 48 48 49 49 // メール送信処理 50 $objSendMail = new SC_SendMail ();50 $objSendMail = new SC_SendMail_Ex(); 51 51 $from = $arrInfo['email03']; 52 52 $error = $arrInfo['email04']; … … 123 123 124 124 // メール送信処理 125 $objSendMail = new SC_SendMail ();125 $objSendMail = new SC_SendMail_Ex(); 126 126 $bcc = $arrInfo['email01']; 127 127 $from = $arrInfo['email03']; … … 156 156 $body = $objMailView->fetch($tplpath); 157 157 // メール送信処理 158 $objSendMail = new SC_SendMail ();158 $objSendMail = new SC_SendMail_Ex(); 159 159 $to = mb_encode_mimeheader($to); 160 160 $bcc = $arrInfo['email01']; … … 170 170 $arrInfo = $objSiteInfo->data; 171 171 // メール送信処理 172 $objSendMail = new SC_SendMail ();172 $objSendMail = new SC_SendMail_Ex(); 173 173 $bcc = $arrInfo['email01']; 174 174 $from = $arrInfo['email03']; -
branches/feature-module-update/html/mobile/require.php
r16393 r16503 37 37 require_once(CLASS_PATH . "SC_UploadFile.php"); 38 38 require_once(CLASS_PATH . "SC_SiteInfo.php"); 39 require_once(CLASS_ PATH . "SC_SendMail.php");39 require_once(CLASS_EX_PATH . "SC_SendMail_Ex.php"); 40 40 require_once(CLASS_PATH . "SC_FormParam.php"); 41 41 require_once(CLASS_PATH . "SC_CartSession.php"); -
branches/feature-module-update/html/require.php
r16393 r16503 35 35 require_once(CLASS_PATH . "SC_UploadFile.php"); 36 36 require_once(CLASS_PATH . "SC_SiteInfo.php"); 37 require_once(CLASS_ PATH . "SC_SendMail.php");37 require_once(CLASS_EX_PATH . "SC_SendMail_Ex.php"); 38 38 require_once(CLASS_PATH . "SC_FormParam.php"); 39 39 require_once(CLASS_PATH . "SC_CartSession.php");
Note: See TracChangeset
for help on using the changeset viewer.