Changeset 1696

Show
Ignore:
Timestamp:
08/25/08 16:03:07 (3 months ago)
Author:
momo-i
Message:

fix multibyte character email

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/admin/mail.php

    r1695 r1696  
    3737                }  
    3838 
     39                // Multi-byte Character Mail 
     40                if(function_exists('mb_language')) { 
     41                        ini_set("mbstring.internal_encoding","UTF-8"); 
     42                        mb_language("uni"); 
     43                } 
     44 
    3945                $clients = AmpacheMail::get_users($_REQUEST['to']);  
    4046 
    4147                foreach ($clients as $client) {  
    42                         $recipient .= $client['fullname'] ." <" . $client['email'] . ">, "; 
     48                        if(function_exists('mb_encode_mimeheader')) { 
     49                                $recipient .= mb_encode_mimeheader($client['fullname']) ." <" . $client['email'] . ">, "; 
     50                        } else { 
     51                                $recipient .= $client['fullname'] ." <" . $client['email'] . ">, "; 
     52                        } 
    4353                } 
    4454                 
     
    4858                // Set the vars on the object 
    4959                AmpacheMail::$recipient = $recipient;  
    50                 AmpacheMail::$from = $GLOBALS['user']->fullname."<".$GLOBALS['user']->email.">"; 
    51                 AmpacheMail::$subject = scrub_in($_REQUEST['subject']);  
    52                 AmpacheMail::$message = scrub_in($_REQUEST['message']);  
     60                if(function_exists('mb_encode_mimeheader')) { 
     61                        $fullname = mb_encode_mimeheader($GLOBALS['user']->fullname); 
     62                } else { 
     63                        $fullname = $GLOBALS['user']->fullname; 
     64                } 
     65                AmpacheMail::$to = $fullname . "<" . $GLOBALS['user']->email . ">"; 
     66                AmpacheMail::$from = $fullname . "<" . $GLOBALS['user']->email . ">"; 
     67                AmpacheMail::$subject = scrub_in($_REQUEST['subject']); 
     68                if(function_exists('mb_eregi_replace')) { 
     69                        AmpacheMail::$message = mb_eregi_replace("\r\n", "\n", scrub_in($_REQUEST['message'])); 
     70                } else { 
     71                        AmpacheMail::$message = scrub_in($_REQUEST['message']); 
     72                } 
     73                AmpacheMail::$additional_header = array(); 
     74                AmpacheMail::$additional_header[] = 'X-Ampache-Mailer: 0.0.1'; 
     75                if(function_exists('mb_send_mail')) { 
     76                        AmpacheMail::$additional_header[] = 'Content-Type: text/plain; charset=UTF-8'; 
     77                        AmpacheMail::$additional_header[] = 'Content-Transfer-Encoding: 8bit'; 
     78                } else { 
     79                        AmpacheMail::$additional_header[] = 'Content-Type: text/plain; charset=us-ascii'; 
     80                        AmpacheMail::$additional_header[] = 'Content-Transfer-Encoding: 7bit'; 
     81                } 
     82                AmpacheMail::$additional_header[] = "From: " . AmpacheMail::$from; 
     83                AmpacheMail::$additional_header[] = "Bcc: $recipient"; 
     84                AmpacheMail::$sender = $GLOBALS['user']->email; 
     85 
    5386                AmpacheMail::send();     
    5487         
  • trunk/lib/class/ampachemail.class.php

    r1445 r1696  
    2727        public static $from;  
    2828        public static $subject;  
     29        public static $to; 
     30        public static $additional_header; 
     31        public static $sender; 
    2932 
    3033        /** 
     
    9093        public static function send() {  
    9194 
    92                 mail(self::$from,self::$subject,self::$message,"From: " . self::$from . "\r\nBcc: " . self::$recipient . "\r\n");  
     95                // Multi-byte Character Mail 
     96                if(function_exists('mb_send_mail')) { 
     97                        mb_send_mail(self::$to, 
     98                                     self::$subject, 
     99                                     self::$message, 
     100                                     implode("\n", self::$additional_header), 
     101                                     '-f'.self::$sender); 
     102                } else { 
     103                        mail(self::$to, 
     104                             self::$subject, 
     105                             self::$message, 
     106                             implode("\r\n", $additional_header), 
     107                             '-f'.self::$sender); 
     108                } 
    93109 
    94110                return true;