Changeset 22567 for branches/version-2_12-dev/data/class/SC_SendMail.php
- Timestamp:
- 2013/02/18 19:09:54 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_SendMail.php
r22206 r22567 23 23 24 24 // テキスト/HTML メール送信 25 class SC_SendMail { 25 class SC_SendMail 26 { 26 27 27 28 var $to; // 送信先 … … 39 40 * @return void 40 41 */ 41 function __construct() { 42 function __construct() 43 { 42 44 $this->arrRecip = array(); 43 45 $this->to = ''; … … 62 64 63 65 // 送信先の設定 64 function setRecip($key, $recipient) { 66 function setRecip($key, $recipient) 67 { 65 68 $this->arrRecip[$key] = $recipient; 66 69 } 67 70 68 71 // 宛先の設定 69 function setTo($to, $to_name = '') { 72 function setTo($to, $to_name = '') 73 { 70 74 if ($to != '') { 71 75 $this->to = $this->getNameAddress($to_name, $to); … … 75 79 76 80 // 送信元の設定 77 function setFrom($from, $from_name = '') { 81 function setFrom($from, $from_name = '') 82 { 78 83 $this->from = $this->getNameAddress($from_name, $from); 79 84 } 80 85 81 86 // CCの設定 82 function setCc($cc, $cc_name = '') { 87 function setCc($cc, $cc_name = '') 88 { 83 89 if ($cc != '') { 84 90 $this->cc = $this->getNameAddress($cc_name, $cc); … … 88 94 89 95 // BCCの設定 90 function setBCc($bcc) { 96 function setBCc($bcc) 97 { 91 98 if ($bcc != '') { 92 99 $this->bcc = $bcc; … … 96 103 97 104 // Reply-Toの設定 98 function setReplyTo($reply_to) { 105 function setReplyTo($reply_to) 106 { 99 107 if ($reply_to != '') { 100 108 $this->reply_to = $reply_to; … … 103 111 104 112 // Return-Pathの設定 105 function setReturnPath($return_path) { 113 function setReturnPath($return_path) 114 { 106 115 $this->return_path = $return_path; 107 116 } 108 117 109 118 // 件名の設定 110 function setSubject($subject) { 119 function setSubject($subject) 120 { 111 121 $this->subject = mb_encode_mimeheader($subject, 'JIS', 'B', "\n"); 112 122 $this->subject = str_replace(array("\r\n", "\r"), "\n", $this->subject); … … 114 124 115 125 // 本文の設定 116 function setBody($body) { 126 function setBody($body) 127 { 117 128 // iso-2022-jpだと特殊文字が?で送信されるのでJISを使用する 118 129 $this->body = mb_convert_encoding($body, 'JIS', CHAR_CODE); … … 124 135 * @deprecated 2.12.2 (#1912) 125 136 */ 126 function setHost($host) { 137 function setHost($host) 138 { 127 139 trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); 128 140 $this->host = $host; … … 141 153 * @deprecated 2.12.2 (#1912) 142 154 */ 143 function setPort($port) { 155 function setPort($port) 156 { 144 157 trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); 145 158 $this->port = $port; … … 153 166 154 167 // 名前<メールアドレス>の形式を生成 155 function getNameAddress($name, $mail_address) { 168 function getNameAddress($name, $mail_address) 169 { 156 170 if ($name != '') { 157 171 // 制御文字を変換する。 … … 166 180 } 167 181 168 function setItem($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') { 182 function setItem($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') 183 { 169 184 $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); 170 185 } 171 186 172 function setItemHtml($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') { 187 function setItemHtml($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') 188 { 173 189 $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); 174 190 } … … 186 202 $bcc -> ブラインドカーボンコピー 187 203 */ 188 function setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') { 204 function setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') 205 { 189 206 // 宛先設定 190 207 $this->setTo($to); … … 213 230 214 231 // ヘッダーを返す 215 function getBaseHeader() { 232 function getBaseHeader() 233 { 216 234 // 送信するメールの内容と送信先 217 235 $arrHeader = array(); … … 236 254 237 255 // ヘッダーを返す 238 function getTEXTHeader() { 256 function getTEXTHeader() 257 { 239 258 $arrHeader = $this->getBaseHeader(); 240 259 $arrHeader['Content-Type'] = 'text/plain; charset="ISO-2022-JP"'; … … 243 262 244 263 // ヘッダーを返す 245 function getHTMLHeader() { 264 function getHTMLHeader() 265 { 246 266 $arrHeader = $this->getBaseHeader(); 247 267 $arrHeader['Content-Type'] = 'text/html; charset="ISO-2022-JP"'; … … 254 274 * @return array|string メーラーバックエンドに応じた送信先 255 275 */ 256 function getRecip() { 276 function getRecip() 277 { 257 278 switch ($this->backend) { 258 279 // PEAR::Mail_mail#send は、(他のメーラーバックエンドと異なり) 第1引数を To: として扱う。Cc: や Bcc: は、ヘッダー情報から処理する。 … … 274 295 * @return void 275 296 */ 276 function sendMail($isHtml = false) { 297 function sendMail($isHtml = false) 298 { 277 299 $header = $isHtml ? $this->getHTMLHeader() : $this->getTEXTHeader(); 278 300 $recip = $this->getRecip(); … … 295 317 * @return void 296 318 */ 297 function sendHtmlMail() { 319 function sendHtmlMail() 320 { 298 321 return $this->sendMail(true); 299 322 } … … 305 328 * @return array メーラーバックエンドに応じたパラメーターの配列 306 329 */ 307 function getBackendParams($backend) { 330 function getBackendParams($backend) 331 { 308 332 switch ($backend) { 309 333 case 'mail':
Note: See TracChangeset
for help on using the changeset viewer.