Hi
I have this script which is sending me emails ok, presumably of my db, but Outlook Express is showing me a load of hexadecimal in the email body not a nice attachment - (it does list it in pane view as having an attachment)
here's the script:
<?php
$datestamp = date("Y-m-d");
$dbuser = "xyz";
$dbpwd = "zxy";
$dbname = "xxdb";
$filename= "/home/barrow/public_html/backup-$datestamp.sql.gz";
$to = "me@x.co.uk";
$from = "theserver";
$subject = "MySQL backup file";
$command = "mysqldump -u $dbuser --password=$dbpwd $dbname | gzip > $filename";
$result = passthru($command);
$attachmentname = array_pop(explode("/", $filename));
$message = "Compressed database backup file $attachmentname attached.";
$mime_boundary = "<<<:" . md5(time());
$data = chunk_split(base64_encode(implode("", file($filename))));
if (!$data) {echo 'data empty';exit;}
$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: multipart/mixed;\r\n";
$headers .= " boundary=\"".$mime_boundary."\"\r\n";
$content = "This is a multi-part message in MIME format.\r\n\r\n";
$content.= "--".$mime_boundary."\r\n";
$content.= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$content.= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$content.= $message."\r\n";
$content.= "--".$mime_boundary."\r\n";
$content.= "Content-Disposition: attachment;\r\n";
$content.= "Content-Type: Application/Octet-Stream; name=\"$attachmentname\"\r\n";
$content.= "Content-Transfer-Encoding: binary\r\n\r\n";
$content.= $data."\r\n";
$content.= "--" . $mime_boundary . "\r\n";
mail($to, $subject, $content, $headers);
unlink($filename);
?>
I thought that octet-stream, binary encode was all I needed?
Outlook reports the attachment as 20k but a mysqladmin copy of the database is 60k - do you think I have something else wrong?
I have looked to see if OutlookExpress is refusing to recognise it but I cant find anything there
thanks