summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormomo-i <momo-i@ampache>2008-08-25 23:03:07 +0000
committermomo-i <momo-i@ampache>2008-08-25 23:03:07 +0000
commit409ece91cc8fa1cb734c4b9754cbe7035cfc6643 (patch)
tree4f6b6375f3ea75cd99e0757fe7e95321f1f8f197
parentbfc0647117c23618952f27c7af843ce6666fa3f4 (diff)
downloadampache-409ece91cc8fa1cb734c4b9754cbe7035cfc6643.tar.gz
ampache-409ece91cc8fa1cb734c4b9754cbe7035cfc6643.tar.bz2
ampache-409ece91cc8fa1cb734c4b9754cbe7035cfc6643.zip
fix multibyte character email
-rw-r--r--admin/mail.php41
-rw-r--r--lib/class/ampachemail.class.php18
2 files changed, 54 insertions, 5 deletions
diff --git a/admin/mail.php b/admin/mail.php
index e2afcda9..8650b468 100644
--- a/admin/mail.php
+++ b/admin/mail.php
@@ -36,10 +36,20 @@ switch ($_REQUEST['action']) {
exit;
}
+ // Multi-byte Character Mail
+ if(function_exists('mb_language')) {
+ ini_set("mbstring.internal_encoding","UTF-8");
+ mb_language("uni");
+ }
+
$clients = AmpacheMail::get_users($_REQUEST['to']);
foreach ($clients as $client) {
- $recipient .= $client['fullname'] ." <" . $client['email'] . ">, ";
+ if(function_exists('mb_encode_mimeheader')) {
+ $recipient .= mb_encode_mimeheader($client['fullname']) ." <" . $client['email'] . ">, ";
+ } else {
+ $recipient .= $client['fullname'] ." <" . $client['email'] . ">, ";
+ }
}
// Remove the last , from the recipient
@@ -47,9 +57,32 @@ switch ($_REQUEST['action']) {
// Set the vars on the object
AmpacheMail::$recipient = $recipient;
- AmpacheMail::$from = $GLOBALS['user']->fullname."<".$GLOBALS['user']->email.">";
- AmpacheMail::$subject = scrub_in($_REQUEST['subject']);
- AmpacheMail::$message = scrub_in($_REQUEST['message']);
+ if(function_exists('mb_encode_mimeheader')) {
+ $fullname = mb_encode_mimeheader($GLOBALS['user']->fullname);
+ } else {
+ $fullname = $GLOBALS['user']->fullname;
+ }
+ AmpacheMail::$to = $fullname . "<" . $GLOBALS['user']->email . ">";
+ AmpacheMail::$from = $fullname . "<" . $GLOBALS['user']->email . ">";
+ AmpacheMail::$subject = scrub_in($_REQUEST['subject']);
+ if(function_exists('mb_eregi_replace')) {
+ AmpacheMail::$message = mb_eregi_replace("\r\n", "\n", scrub_in($_REQUEST['message']));
+ } else {
+ AmpacheMail::$message = scrub_in($_REQUEST['message']);
+ }
+ AmpacheMail::$additional_header = array();
+ AmpacheMail::$additional_header[] = 'X-Ampache-Mailer: 0.0.1';
+ if(function_exists('mb_send_mail')) {
+ AmpacheMail::$additional_header[] = 'Content-Type: text/plain; charset=UTF-8';
+ AmpacheMail::$additional_header[] = 'Content-Transfer-Encoding: 8bit';
+ } else {
+ AmpacheMail::$additional_header[] = 'Content-Type: text/plain; charset=us-ascii';
+ AmpacheMail::$additional_header[] = 'Content-Transfer-Encoding: 7bit';
+ }
+ AmpacheMail::$additional_header[] = "From: " . AmpacheMail::$from;
+ AmpacheMail::$additional_header[] = "Bcc: $recipient";
+ AmpacheMail::$sender = $GLOBALS['user']->email;
+
AmpacheMail::send();
/* Confirmation Send */
diff --git a/lib/class/ampachemail.class.php b/lib/class/ampachemail.class.php
index 2747876b..8097bc32 100644
--- a/lib/class/ampachemail.class.php
+++ b/lib/class/ampachemail.class.php
@@ -26,6 +26,9 @@ class AmpacheMail {
public static $recipient;
public static $from;
public static $subject;
+ public static $to;
+ public static $additional_header;
+ public static $sender;
/**
* Constructor
@@ -89,7 +92,20 @@ class AmpacheMail {
*/
public static function send() {
- mail(self::$from,self::$subject,self::$message,"From: " . self::$from . "\r\nBcc: " . self::$recipient . "\r\n");
+ // Multi-byte Character Mail
+ if(function_exists('mb_send_mail')) {
+ mb_send_mail(self::$to,
+ self::$subject,
+ self::$message,
+ implode("\n", self::$additional_header),
+ '-f'.self::$sender);
+ } else {
+ mail(self::$to,
+ self::$subject,
+ self::$message,
+ implode("\r\n", $additional_header),
+ '-f'.self::$sender);
+ }
return true;