replaceImages => true|false,
locale => 'en' .... or zh_hk....
rcpts => array() // override recipients..
+ attachments => array(
+ array(
+ file:
+ name : (optional) - uses basename of file
+ mimetype :
+ ),
+ ......
+
]
*
* recipents is gathered from the resulting template
//exit;
}
+ $isMine = false;
+
require_once 'Mail/mime.php';
$mime = new Mail_mime(array(
'eol' => "\n",
$cdata['contentid']
);
}
- $parts[2] = $mime->get();
- $parts[1] = $mime->headers($parts[1]);
-
+ $isMine = true;
}
-// echo '<PRE>';
-// print_r('parts');
-// print_r($parts);exit;
+
if($this->attachments){
//if got a attachments
- if (isset($parts[1]['Content-Type'])) {
- unset($parts[1]['Content-Type']);
+
+ $header = $mime->headers($parts[1]);
+
+ if(preg_match('/text\/html/', $header['Content-Type'])){
+ $mime->setHTMLBody($parts[2]);
+ }else{
+ $mime->setTXTBody($parts[2]);
}
- $random_hash = md5(date('r', time()));
- $parts[1]['Content-Type'] = "multipart/mixed; boundary=mixed-$random_hash";
-// --mixed-{t.random_hash}
-//Content-Type: multipart/alternative; boundary=alt-{t.random_hash}
-//
-//--alt-{t.random_hash}
-//Content-Type: text/plain; charset=utf-8
-//Content-Transfer-Encoding: 7bit
-//
-//{t.msg}
-//
-//--alt-{t.random_hash}--
-//
-//--mixed-{t.random_hash}
-//Content-Type: application/pdf; name="doc.pdf"
-//Content-Transfer-Encoding: base64
-//Content-Disposition: attachment
-//
-//{t.attach}
-//--mixed-{t.random_hash}--
+ foreach($this->attachments as $attch){
+ $mime->addAttachment(
+ $attch['file'],
+ $attch['mimetype'],
+ $attch['name'],
+ false
+ );
+ }
+
+ $isMine = true;
}
-
+ if($isMine){
+ $parts[2] = $mime->get();
+ $parts[1] = $mime->headers($parts[1]);
+ }
+// echo '<PRE>';
+// print_r('parts');
+// print_r($parts[2]);
+// exit;
// list($recipents,$headers,$body) = $parts;
return array(
'recipents' => $parts[0],