Fix charset of the NL (ugly hack)
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 1 Dec 2006 15:59:14 +0000 (15:59 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 1 Dec 2006 15:59:14 +0000 (15:59 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/branches/platal-0.9.12@1218 839d8a87-29fc-0310-9880-83ba4fa771e5

include/newsletter.inc.php

index 482a61d..d66dce2 100644 (file)
@@ -333,23 +333,40 @@ EOF;
     function sendTo($prenom, $nom, $login, $sex, $html)
     {
         global $globals;
-    require_once('diogenes/diogenes.hermes.inc.php');
+        require_once('diogenes/diogenes.hermes.inc.php');
 
-    $mailer = new HermesMailer();
-    $mailer->setFrom($globals->newsletter->from);
-    $mailer->setSubject($this->title(true));
-    $mailer->addTo("\"$prenom $nom\" <$login@{$globals->mail->domain}>");
+        $mailer = new HermesMailer();
+        $mailer->setFrom($globals->newsletter->from);
+        $mailer->setSubject($this->title(true));
+        $mailer->addTo("\"$prenom $nom\" <$login@{$globals->mail->domain}>");
         if (!empty($globals->newsletter->replyto)) {
             $mailer->addHeader('Reply-To',$globals->newsletter->replyto);
         }
         if (!empty($globals->newsletter->retpath)) {
             $mailer->addHeader('Return-Path',$globals->newsletter->retpath);
         }
-    $mailer->setTxtBody($this->toText($prenom,$nom,$sex));
-    if ($html) {
-        $mailer->setHTMLBody($this->toHtml($prenom,$nom,$sex,true));
-    }
-    $mailer->send();
+        $mailer->setTxtBody($this->toText($prenom,$nom,$sex));
+        if ($html) {
+            $mailer->setHTMLBody($this->toHtml($prenom,$nom,$sex,true));
+        }
+
+        /** ugly import from Hermes in order to change message charset **/
+        $addrs = Array();
+        foreach(Array('To', 'Cc', 'Bcc') as $hdr) {
+            if(isset($mailer->_headers[$hdr])) {
+                require_once 'Mail/RFC822.php';
+                $addrs = array_merge($addrs, Mail_RFC822::parseAddressList($mailer->_headers[$hdr]));
+            }
+        }
+        if(empty($addrs)) return false;
+
+        $dests = Array();
+        foreach($addrs as $a) $dests[] = "{$a->mailbox}@{$a->host}";
+
+        // very important to do it in THIS order very precisely.
+        $body = $mailer->get(array('text_charset' => 'ISO-8859-15', 'html_charset' => 'ISO-8859-15'));
+        $hdrs = $mailer->headers();
+        return $mailer->_mail->send($dests, $hdrs, $body);
     }
 
     // }}}