*
* $x= new Pman_Core_Mailer($opts)
*
- * $opts[
+ * $x= Pman_Core_Mailer(array(
page =>
contents
template
mimetype :
),
......
+ mail_method : (SMTP or SMTPMX)
- ]
+ )
*
* 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();
var $templateDir = false;
var $locale = false; // eg. 'en' or 'zh_HK'
+
var $html_locale = false; // eg. 'en' or 'zh_HK'
var $images = array(); // generated list of cid images for sending
var $attachments = false;
+ var $mail_method = 'SMTP';
+
function Pman_Core_Mailer($args) {
foreach($args as $k=>$v) {
// a bit trusting..
$htmltemplate->compile('mail/'. $templateFile.'.body.html');
$htmlbody = $htmltemplate->bufferedOutputObject($content);
+ $this->htmlbody = $htmlbody;
+
// for the html body, we may want to convert the attachments to images.
// var_dump($htmlbody);exit;
if ($this->replaceImages) {
return array(
'recipents' => $parts[0],
'headers' => $parts[1],
- 'body' => $parts[2]
+ 'body' => $parts[2],
+ 'mailer' => $this
);
}
function send($email = false)
$email = is_array($email) ? $email : $this->toData();
- print_r($email);exit;
if (is_a($email, 'PEAR_Error')) {
$pg->addEvent("COREMAILER-FAIL", false, "email toData failed");
///$recipents = array($this->email);
$mailOptions = PEAR::getStaticProperty('Mail','options');
//print_R($mailOptions);exit;
- $mail = Mail::factory("SMTP",$mailOptions);
+
+ if ($this->mail_method == 'SMTPMX' && empty($mailOptions['mailname'])) {
+ $pg->jerr("Mail[mailname] is not set - this is required for SMTPMX");
+
+ }
+
+ $mail = Mail::factory($this->mail_method,$mailOptions);
+ if ($this->debug) {
+ $mail->debug = $this->debug;
+ }
+
$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;
'To: ' . ( is_array($rcpts) ? implode(', ', $rcpts) : $rcpts ) .
'Subject: ' . @$email['headers']['Subject']
);
- }
-
+ } else {
+ $pg->addEvent("COREMAILER-FAIL", false, $ret->toString());
+ }
+
return $ret;
}