require_once($path_to_root . "/reporting/includes/class.mail.inc");
$company = get_company_prefs();
$mail = new email($company['coy_name'], $company['email']);
- $to = $loc['location_name'] . " <" . $loc['email'] . ">";
$subject = _("Stocks below Re-Order Level at ") . $loc['location_name'];
$msg = "\n";
for ($i = 0; $i < count($st_ids); $i++)
$msg .= $st_ids[$i] . " " . $st_names[$i] . ", " . _("Re-Order Level") . ": " . $st_reorder[$i] . ", " . _("Below") . ": " . $st_num[$i] . "\n";
$msg .= "\n" . _("Please reorder") . "\n\n";
$msg .= $company['coy_name'];
- $mail->to($to);
+ $mail->to($loc['location_name'], $loc['email']);
$mail->subject($subject);
$mail->text($msg);
return $mail->send();
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" <adr@host>'.
+ // 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)
function subject($subject)
{
- $this->subject = $subject;
+ $this->subject = $this->encode($subject);
}
function text($text)
{
// 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
continue;
$emailtype = true;
$this->SetLang($contact['lang']);
+ $coy_name = @html_entity_decode($this->company['coy_name'], ENT_QUOTES, $_SESSION['language']->encoding=='iso-8859-2' ? 'ISO-8859-1' : $_SESSION['language']->encoding);
require_once($path_to_root . "/reporting/includes/class.mail.inc");
- $mail = new email(str_replace(",", "", $this->company['coy_name']),
+ $mail = new email(str_replace(",", "", $coy_name),
$this->company['email']);
$mail->charset = $this->encoding;
- $to = str_replace(",", "", $contact['name'].' '.$contact['name2'])
- ." <" . $contact['email'] . ">";
$msg = _("Dear") . " " . $contact['name2'] . ",\n\n"
. _("Attached you will find ") . " " . $subject ."\n\n";
}
$msg .= _("Kindest regards") . "\n\n";
- $sender = $this->user . "\n" . $this->company['coy_name'] . "\n" . $this->company['postal_address'] . "\n" . $this->company['email'] . "\n" . $this->company['phone'];
- $mail->to($to); $try++;
+ $sender = $this->user . "\n" . $coy_name . "\n" . $this->company['postal_address'] . "\n" . $this->company['email'] . "\n" . $this->company['phone'];
+ $mail->to(str_replace(",", "", $contact['name'].' '.$contact['name2']), $contact['email']);
+ $try++;
$mail->subject($subject);
$mail->text($msg . $sender);
$mail->attachment($fname, $this->filename);
$rep->Font();
if ($email == 1)
{
- $rep->End($email, sprintf(_("Invoice %s from %s"), $myrow['reference'], get_company_pref('coy_name')));
+ $rep->End($email, sprintf(_("Invoice %s from %s"), $myrow['reference'], htmlspecialchars_decode(get_company_pref('coy_name'))));
}
}
if ($email == 0)
if ($email == 1)
{
if (($CustomerRecord["Balance"]) != ($CustomerRecord["Balance"] - $CustomerRecord["Due"]))
- $rep->End($email, _("Statement") . " " . _("as of") . " " . sql2date($date) . " " . _("from") . " " . get_company_pref('coy_name'));
+ $rep->End($email, _("Statement") . " " . _("as of") . " " . sql2date($date) . " " . _("from") . " " . htmlspecialchars_decode(get_company_pref('coy_name')));
else
display_notification(sprintf(_("Customer %s has no overdue debits. No e-mail is sent."), $myrow["DebtorName"]));
}