*
* $x= new Pman_Core_Mailer($opts)
*
- * $opts[
+ * $x= Pman_Core_Mailer(array(
page =>
contents
template
+ html_locale => 'en' == always use the 'english translated verison'
replaceImages => true|false,
locale => 'en' .... or zh_hk....
rcpts => array() // override recipients..
),
......
- ]
+ )
*
* recipents is gathered from the resulting template
* -- eg.
* if the file '
*
*
- * $x->asData(); // returns data needed for notify?? - notify should really
+ * $x->toData(); // returns data needed for notify?? - notify should really
* // just use this to pass around later..
*
* $x->send();
// for the html body, we may want to convert the attachments to images.
// var_dump($htmlbody);exit;
- $htmlbody = $this->htmlbodytoCID($htmlbody);
+ if ($this->replaceImages) {
+ $htmlbody = $this->htmlbodytoCID($htmlbody);
+ }
}
'body' => $parts[2]
);
}
- function send()
+ function send($email = false)
{
$pg = HTML_FlexyFramework::get()->page;
- $email = $this->toData();
+ $email = is_array($email) ? $email : $this->toData();
if (is_a($email, 'PEAR_Error')) {
$pg->addEvent("COREMAILER-FAIL", false, "email toData failed");
$mailOptions = PEAR::getStaticProperty('Mail','options');
//print_R($mailOptions);exit;
$mail = Mail::factory("SMTP",$mailOptions);
- $headers['Date'] = date('r');
+ $email['headers']['Date'] = date('r');
if (PEAR::isError($mail)) {
- $pg->addEvent("COREMAILER-FAIL", false, "mail factory failed");
+ $pg->addEvent("COREMAILER-FAIL", false, "mail factory failed");
return $mail;
error_reporting($oe);
if ($ret === true) {
$pg->addEvent("COREMAILER-SENT", false,
- 'To: ' . implode(', ', $rcpts) .
- 'Subject ' . $headers['subject']
+ 'To: ' . ( is_array($rcpts) ? implode(', ', $rcpts) : $rcpts ) .
+ 'Subject: ' . @$email['headers']['Subject']
);
-
+ }
return $ret;
}
foreach ($imgs as $i=>$img) {
$url = $img->getAttribute('src');
+ if (preg_match('#^cid:#', $url)) {
+ continue;
+ }
$conv = $this->fetchImage($url);
$this->images[$conv['contentid']] = $conv;
$cache = ini_get('session.save_path')."/Pman_Core_Mailer-{$user}/" . md5($url);
if (file_exists($cache) and filemtime($cache) > strtotime('NOW - 1 WEEK')) {
- $ret = json_decode($cache);
+ $ret = json_decode(file_get_contents($cache), true);
$ret['file'] = $cache . '.data';
return $ret;
}