//exit;
}
- $isMine = false;
+ $isMime = false;
require_once 'Mail/mime.php';
$mime = new Mail_mime(array(
$cdata['contentid']
);
}
- $parts[2] = $mime->get();
- $parts[1] = $mime->headers($parts[1]);
-
+ $isMime = true;
}
- echo '<PRE>';
- print_r('parts');
- print_r($parts);exit;
- if($this->attachments){
+
+ if(!empty($this->attachments)){
//if got a attachments
- $contentType = 'Content-Type: text/plain; charset=utf-8';
+ $header = $mime->headers($parts[1]);
+
if (isset($parts[1]['Content-Type'])) {
- $contentType = $parts[1]['Content-Type'];
unset($parts[1]['Content-Type']);
}
+ if (!$isMime) {
+
+ if(preg_match('/text\/html/', $header['Content-Type'])){
+ $mime->setHTMLBody($parts[2]);
+ $mime->setTXTBody('This message is in HTML only');
+ }else{
+ $mime->setTXTBody($parts[2]);
+ $mime->setHTMLBody('<PRE>'.htmlspecialchars($parts[2]).'</PRE>');
+ }
+ }
foreach($this->attachments as $attch){
- $mine->addAttachment(
+ $mime->addAttachment(
$attch['file'],
- $attch['mimetype']
- $attch['name']
-
+ $attch['mimetype'],
+ (!empty($attch['name'])) ? $attch['name'] : '',
+ true
);
-
}
-
-
- /*
- $random_hash = md5(date('r', time()));
- $parts[1]['Content-Type'] = "multipart/mixed; boundary=mixed-$random_hash";
-
-$str = "
---mixed-$random_hash
-Content-Type: multipart/alternative; boundary=alt-$random_hash
-
---alt-$random_hash
-Content-Type: $contentType
-
-{$parts[2]}
-
---alt-$random_hash--
-
-";
-
-foreach($this->attachments as $attch){
-$str .= "
---mixed-$random_hash
-Content-Type: {$attch['mimetype']}; ".
-((empty($attch['name'])) ? '' : "name=\"{$attch['name']}\"") .
-"Content-Transfer-Encoding: base64
-Content-Disposition: attachment
-
-{$attch['file']}
-";
-}
- $str .= "--mixed-$random_hash--";
-
- $parts[2] = $str;
- *
- */
+ $isMime = true;
}
- $isMine;
-
+ if($isMime){
+ $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],