Changeset 16276


Ignore:
Timestamp:
2007/10/05 21:39:37 (16 years ago)
Author:
naka
Message:

GC_SendMailウィンドウズ対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/GC_SendMail.php

    r15532 r16276  
    1717    var $mailer; 
    1818 
     19    function setTo($to, $to_name = "") { 
     20        if($to_name != "") { 
     21            $name = ereg_replace("<","<", $to_name); 
     22            $name = ereg_replace(">",">", $name); 
     23             
     24            if(WINDOWS != true) { 
     25                // windowsでは文字化けするので使用しない。 
     26                $name = mb_convert_encoding($name,"JIS",CHAR_CODE);  
     27            } 
     28             
     29            $name = mb_encode_mimeheader($name); 
     30            $this->to = $name . "<" . $to . ">"; 
     31        } else { 
     32            $this->to = $to; 
     33        } 
     34    } 
     35     
     36    function setItem( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 
     37        $this->header        = "Mime-Version: 1.0\n"; 
     38        $this->header       .= "Content-Type: text/plain; charset=ISO-2022-JP\n"; 
     39        $this->header       .= "Content-Transfer-Encoding: 7bit\n"; 
     40        $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); 
     41    } 
     42         
     43    function setItemHtml( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 
     44        $this->header        = "Mime-Version: 1.0\n"; 
     45        $this->header       .= "Content-Type: text/html; charset=ISO-2022-JP\n"; 
     46        $this->header       .= "Content-Transfer-Encoding: 7bit\n"; 
     47        $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); 
     48    } 
     49 
    1950    /*  ヘッダ等を格納 
    2051         $to            -> 送信先メールアドレス 
     
    2859         $cc            -> カーボンコピー 
    2960         $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          
     61    */       
     62    function setBase( $to, $subject, $body, $fromaddress, $from_name, $reply_to="", $return_path="", $errors_to="", $bcc="", $cc ="" ) { 
    4663        $this->to            = $to; 
    47         $this->subject       = $subject; 
     64        $this->subject       = mb_encode_mimeheader($subject); 
    4865 
    4966        // iso-2022-jpだと特殊文字が?で送信されるのでJISを使用する。 
    5067        $this->body          = mb_convert_encoding( $body, "JIS", CHAR_CODE); 
    51  
     68                 
    5269        // ヘッダーに日本語を使用する場合はMb_encode_mimeheaderでエンコードする。 
    5370        $from_name = ereg_replace("<","<", $from_name); 
    5471        $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"; 
    6172         
    62         $this->return_path   = $return_path; 
     73        if(WINDOWS != true) { 
     74            // windowsでは文字化けするので使用しない。 
     75            $from_name = mb_convert_encoding($from_name,"JIS",CHAR_CODE);        
     76        } 
     77         
     78        $this->header.= "From: ". mb_encode_mimeheader( $from_name )."<".$fromaddress.">\n"; 
     79 
     80        if($reply_to != "") { 
     81            $this->header.= "Reply-To: ". $reply_to . "\n";          
     82        } else { 
     83            $this->header.= "Reply-To: ". $fromaddress . "\n";           
     84        } 
     85         
     86        if($cc != "") { 
     87            $this->header.= "Cc: " . $cc. "\n";          
     88        } 
     89         
     90        if($bcc != "") { 
     91            $this->header.= "Bcc: " . $bcc . "\n";           
     92        } 
     93 
     94        if($errors_to != "") { 
     95            $this->header.= "Errors-To: ". $errors_to ."\n"; 
     96        } 
    6397    } 
    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  
     98     
    8199    //  メール送信を実行する 
    82100    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; 
     101        return $this->sendHtmlMail(); 
    91102    } 
    92103 
    93104    function sendHtmlMail() { 
    94  
    95         Mb_language( "Japanese" );   
    96          
    97105        // メール送信 
    98106        if( mail( $this->to, $this->subject, $this->body, $this->header) ) { 
Note: See TracChangeset for help on using the changeset viewer.