Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/mail
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv597/modules/mail
Added Files:
class.module_mail.php
Log Message:
restructured directory module/
--- NEW FILE: class.module_mail.php ---
<?php
class module_mail extends module {
function module_mail (&$eventhandler) {
return $this->__construct ($eventhandler);
}
function init () {
$this->__registerEvent ('MAIL_SEND_MAIL', 'sendMail');
}
function sendMail ($actiondata) {
return mail ($actiondata['to'], $actiondata['subject'], $actiondata['message'], $actiondata['header']);
}
function mail_attach($to, $from, $subject, $message, $files = FALSE,$lb="\n") {
// $to Recipient
// $from Sender (like "em...@do..." or "Name <em...@do...>")
// $subject Subject
// $message Content
// $files hash-array of files to attach
// $lb is linebreak characters... some mailers need \r\n, others need \n
// check if each attached file realy exists
$mime_boundary = '<<<:' . md5(uniqid(mt_rand(), 1));
$header = 'From: '.$from;
if(is_array($files)) {
$header.= $lb.'MIME-Version: 1.0'.$lb.'Content-Type: multipart/mixed;'.$lb.
' boundary="'.$mime_boundary.'"'.$lb;
$content = 'This is a multi-part message in MIME format.'.$lb.$lb.
'--'.$mime_boundary.$lb.'Content-Type: text/plain; charset="iso-8859-1"'.$lb.
'Content-Transfer-Encoding: 7bit'.$lb.$lb;
}
$content.= $message.$lb;
if (is_array ($files)) {
$content.= '--'.$mime_boundary.$lb;
foreach($files as $filename=>$filelocation) {
if(is_readable($filelocation)) {
$data = chunk_split(base64_encode(implode("", file($filelocation))));
$content.= 'Content-Disposition: attachment;'.$lb.
'Content-Type: Application/Octet-Stream;'.
' name="'.$filename.'"'.$lb.
'Content-Transfer-Encoding: base64".$lb.$lb.
$data.$lb.'--'.$mime_boundary.$lb;
}
}
}
if(mail($to, $subject, $content, $header)) {
return true;
}
return FALSE;
}
}
?>
|