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);
}
// }}}