X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=reporting%2Fincludes%2Fclass.mail.inc;h=583a20a489032b0c1342dd4995cbc5d2f0c9462a;hb=0cbe5791fbc7f09ab9dda6b92d1ae27e61d26953;hp=9ae05ea9acca9686041ff762edb7a1414c75a13f;hpb=331673104c056da093f60cde57d731371fbdc6ee;p=fa-stable.git diff --git a/reporting/includes/class.mail.inc b/reporting/includes/class.mail.inc index 9ae05ea9..583a20a4 100644 --- a/reporting/includes/class.mail.inc +++ b/reporting/includes/class.mail.inc @@ -44,25 +44,43 @@ class email function __construct($name, $mail) { $this->boundary = md5(uniqid(time())); - $this->headers['From'] = "$name <$mail>"; + $this->headers['From'] = $this->encode($name)." <$mail>"; + $bcc = get_company_pref('bcc_email'); if ($bcc) $this->bcc[] = $bcc; } - function to($mail) + function encode($txt) + { + + $opts = array('input-charset' => $_SESSION['language']->encoding, + 'output-charest' => 'utf-8', // utf-8 works always nowadays + 'line-length'=> 72, + 'linebreak-chars'=>'\n', + 'scheme' => 'Q', + ); + return substr(iconv_mime_encode(null, $txt, $opts), 2); + } + + // + // For backward compatibility in extensions address can be passed + // in $name in form: '"full name" '. + // Don't use this form unless all the mail addresses are encoded in ASCII + // + function to($name, $mail='') { - $this->to[] = $mail; + $this->to[] = $mail=='' ? $name : ($this->encode($name)." <$mail>"); } - function cc($mail) + function cc($name, $mail='') { - $this->cc[] = $mail; + $this->cc[] = $mail=='' ? $name : ($this->encode($name)." <$mail>"); } - function bcc($mail) + function bcc($name='', $mail='') { - $this->bcc[] = $mail; + $this->bcc[] = $mail=='' ? $name : ($this->encode($name)." <$mail>"); } function attachment($file, $filename=null) @@ -74,7 +92,7 @@ class email function subject($subject) { - $this->subject = $subject; + $this->subject = $this->encode($subject); } function text($text) @@ -120,11 +138,11 @@ class email { // Add CC Recipients if (!empty($this->cc)) - $this->headers['Cc'] = implode(", ", $this->cc); + $this->headers['Cc'] = implode(", ", $this->cc); // Add BCC Recipients if (!empty($this->bcc)) - $this->headers['Bcc'] = implode(", ", $this->bcc); + $this->headers['Bcc'] = implode(", ", $this->bcc); $this->headers['Content-Type'] = "multipart/mixed;\n boundary=\"$this->boundary\""; // Add Attachments