Changeset 1696 for trunk/admin/mail.php

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

fix multibyte character email

Files:
1 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