SaintDog
07-11-2006, 09:46 PM
Below is the function I currently have for mailing, however the attachment isn't being attached. The location of the attachment is correct, however the function doesn't seem to attach it and mail it.
Any help would be greatly appreciated
function mailpackage ($email, $filename, $subject, $body) {
global $emailconfig;
$fromemail = $emailconfig['fromemail'];
$fromname = $emailconfig['fromname'];
$realfilename = $emailconfig['secretfolder'].'/'.$filename;
$mime_boundary = '==Multipart_Boundary_x'.md5(time()).'x';
$crlf = "\r\n";
$fp = fopen($realfilename,'rb');
$filedata = fread($fp, filesize($realfilename));
fclose($fp);
$headers = 'From: '.$fromname.' <'.$fromemail.'>'.$crlf.
'MIME-Version: 1.0'.$crlf.
'X-Mailer: PHP 4.x'.$crlf.
'X-Priority: 3'.$crlf.
'Content-Type: multipart/mixed;'.$crlf.
' boundary="'.$mime_boundary.'"';
$message = 'This is a multi-part message in MIME format.'.$crlf.$crlf.
'--'.$mime_boundary.$crlf.
'Content-Type: text/plain; charset="iso-8859-1"'.$crlf.
'Content-Transfer-Encoding: 7bit'.$crlf.$crlf.
str_replace($mime_boundary, '', $body).
$crlf.$crlf.'--'.$mime_boundary.$crlf.
'Content-Type: application/x-zip;'.$crlf.
' name="'.$filename.'"'.$crlf.
'Content-Disposition: attachment;'.$crlf.
' filename="'.$filename.'"'.$crlf.
'Content-Transfer-Encoding: base64'.$crlf.$crlf.
$crlf.'--'.$mime_boundary.'--'.$crlf;
mail($email, $subject, $message, $headers);
}
Any help would be greatly appreciated
function mailpackage ($email, $filename, $subject, $body) {
global $emailconfig;
$fromemail = $emailconfig['fromemail'];
$fromname = $emailconfig['fromname'];
$realfilename = $emailconfig['secretfolder'].'/'.$filename;
$mime_boundary = '==Multipart_Boundary_x'.md5(time()).'x';
$crlf = "\r\n";
$fp = fopen($realfilename,'rb');
$filedata = fread($fp, filesize($realfilename));
fclose($fp);
$headers = 'From: '.$fromname.' <'.$fromemail.'>'.$crlf.
'MIME-Version: 1.0'.$crlf.
'X-Mailer: PHP 4.x'.$crlf.
'X-Priority: 3'.$crlf.
'Content-Type: multipart/mixed;'.$crlf.
' boundary="'.$mime_boundary.'"';
$message = 'This is a multi-part message in MIME format.'.$crlf.$crlf.
'--'.$mime_boundary.$crlf.
'Content-Type: text/plain; charset="iso-8859-1"'.$crlf.
'Content-Transfer-Encoding: 7bit'.$crlf.$crlf.
str_replace($mime_boundary, '', $body).
$crlf.$crlf.'--'.$mime_boundary.$crlf.
'Content-Type: application/x-zip;'.$crlf.
' name="'.$filename.'"'.$crlf.
'Content-Disposition: attachment;'.$crlf.
' filename="'.$filename.'"'.$crlf.
'Content-Transfer-Encoding: base64'.$crlf.$crlf.
$crlf.'--'.$mime_boundary.'--'.$crlf;
mail($email, $subject, $message, $headers);
}