source: branches/dev/data/class/GC_SendMail.php @ 14873

Revision 14873, 3.0 KB checked in by kakinaka, 17 years ago (diff)
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(mb_convert_encoding($name, "JIS", CHAR_CODE));
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
49        // iso-2022-jp¤À¤ÈÆüìʸ»ú¤¬¡©¤ÇÁ÷¿®¤µ¤ì¤ë¤Î¤ÇJIS¤ò»ÈÍѤ¹¤ë¡£
50        $this->body          = mb_convert_encoding( $body, "JIS", CHAR_CODE);
51
52        // ¥Ø¥Ã¥À¡¼¤ËÆüËܸì¤ò»ÈÍѤ¹¤ë¾ì¹ç¤ÏMb_encode_mimeheader¤Ç¥¨¥ó¥³¡¼¥É¤¹¤ë¡£
53        $from_name = ereg_replace("<","¡ã", $from_name);
54        $from_name = ereg_replace(">","¡ä", $from_name);
55        $from_name = mb_convert_encoding($from_name,"JIS",CHAR_CODE);
56        $this->header        = "From: ". Mb_encode_mimeheader( $from_name )."<".$fromaddress.">\n";
57        $this->header       .= "Reply-To: ". $reply_to . "\n";
58        $this->header       .= "Cc: " . $cc. "\n";
59        $this->header       .= "Bcc: " . $bcc . "\n";
60        $this->header       .= "Errors-To: ". $errors_to ."\n";
61       
62        $this->return_path   = $return_path;
63    }
64
65    function setItemHtml( $to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to="", $bcc="", $cc ="" ) {
66           
67        $this->to            = $to;
68        $this->subject       = mb_encode_mimeheader($subject);
69        $this->body          = mb_convert_encoding( $body, "JIS", CHAR_CODE);
70        $this->header        = "Mime-Version: 1.0\n";
71        $this->header       .= "Content-Type: text/html; charset=iso-2022-jp\n";
72        $this->header       .= "Content-Transfer-Encoding: 7bit\n";
73        $this->header       .= "From: ". Mb_encode_mimeheader( $from_name )."<".$fromaddress.">\n";
74        $this->header       .= "Reply-To: ". $reply_to . "\n";
75        $this->header       .= "Cc: " . $cc. "\n";
76        $this->header       .= "Bcc: " . $bcc . "\n";
77        $this->header       .= "Errors-To: ". $errors_to ."\n";
78        $this->return_path   = $return_path;
79    }
80
81    //  ¥á¡¼¥ëÁ÷¿®¤ò¼Â¹Ô¤¹¤ë
82    function sendMail() {
83
84        Mb_language( "Japanese" );
85       
86        //¡¡¥á¡¼¥ëÁ÷¿®
87        if( mb_send_mail( $this->to, $this->subject, $this->body, $this->header) ) {
88            return true;
89        }
90        return false;
91    }
92
93    function sendHtmlMail() {
94
95        Mb_language( "Japanese" ); 
96       
97        //¡¡¥á¡¼¥ëÁ÷¿®
98        if( mail( $this->to, $this->subject, $this->body, $this->header) ) {
99            return true;
100        }
101        return false;
102    }
103}
104
105?>
Note: See TracBrowser for help on using the repository browser.