source: branches/comu/data/class/GC_SendMail.php @ 11729

Revision 11729, 3.0 KB checked in by nanasess, 19 years ago (diff)

UTF-8 へ変換

Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8//--- テキスト/HTML メール送信
9class GC_SendMail {
10
11    var $html;          //  HTML メールヘッダー
12    var $to;            //  送信先
13    var $subject;       //  題名
14    var $body;          //  本文
15    var $header;        //  ヘッダー
16    var $return_path;   // return path
17    var $mailer;
18
19    /*  ヘッダ等を格納
20         $to            -> 送信先メールアドレス
21         $subject       -> メールのタイトル
22         $body          -> メール本文
23         $fromaddress   -> 送信元のメールアドレス
24         $header        -> ヘッダー
25         $from_name     -> 送信元の名前(全角OK)
26         $reply_to      -> reply_to設定
27         $return_path   -> return-pathアドレス設定(エラーメール返送用)
28         $cc            -> カーボンコピー
29         $bcc           -> ブラインドカーボンコピー
30    */ 
31   
32   
33    function setTo($to, $to_name = "") {
34        if($to_name != "") {
35            $name = ereg_replace("<","<", $to_name);
36            $name = ereg_replace(">",">", $name);
37            $name = mb_encode_mimeheader($name);
38            $this->to = $name . "<" . $to . ">";
39        } else {
40            $this->to = $to;
41        }
42    }
43       
44    function setItem( $to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to="", $bcc="", $cc ="" ) {
45       
46        $this->to            = $to;
47        $this->subject       = $subject;
48        $this->body          = $body;
49        // ヘッダーに日本語を使用する場合はMb_encode_mimeheaderでエンコードする。
50        $from_name = ereg_replace("<","<", $from_name);
51        $from_name = ereg_replace(">",">", $from_name);
52               
53        $this->header        = "From: ". Mb_encode_mimeheader( $from_name )."<".$fromaddress.">\n";
54        $this->header       .= "Reply-To: ". $reply_to . "\n";
55        $this->header       .= "Cc: " . $cc. "\n";
56        $this->header       .= "Bcc: " . $bcc . "\n";
57        $this->header       .= "Errors-To: ". $errors_to ."\n";
58        $this->return_path   = $return_path;
59    }
60
61   
62    function setItemHtml( $to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to="", $bcc="", $cc ="" ) {
63           
64        $this->to            = $to;
65        $this->subject       = Mb_encode_mimeheader($subject);
66        $this->body          = mb_convert_encoding( $body, "iso-2022-jp", CHAR_CODE);
67        $this->header        = "Mime-Version: 1.0\n";
68        $this->header       .= "Content-Type: text/html; charset=iso-2022-jp\n";
69        $this->header       .= "Content-Transfer-Encoding: 7bit\n";
70        $this->header       .= "From: ". Mb_encode_mimeheader( $from_name )."<".$fromaddress.">\n";
71        $this->header       .= "Reply-To: ". $reply_to . "\n";
72        $this->header       .= "Cc: " . $cc. "\n";
73        $this->header       .= "Bcc: " . $bcc . "\n";
74        $this->header       .= "Errors-To: ". $errors_to ."\n";
75        $this->return_path   = $return_path;
76    }
77
78    //  メール送信を実行する
79    function sendMail() {
80
81        Mb_language( "Japanese" );
82       
83        // メール送信
84        if( mb_send_mail( $this->to, $this->subject, $this->body, $this->header, "" . $this->return_path ) ) {
85            return true;
86        }
87        return false;
88    }
89
90    function sendHtmlMail() {
91
92        Mb_language( "Japanese" ); 
93       
94        // メール送信
95        if( mail( $this->to, $this->subject, $this->body, $this->header, "" . $this->return_path ) ) {
96            return true;
97        }
98        return false;
99    }
100}
101
102?>
Note: See TracBrowser for help on using the repository browser.