Hi there thanks for looking. the problem I have with this script is not attaching the file this works fine however i have a database table holding emails ready to be sent to people with a message body or contents. when i run this script it sends the attachment no problem but will not show the actual txt contents of the email.
I was wondering if anyone can spot a problem when you look at the script.
I can't see what is wrong with this code inorder for a message body to be added alsoie the $row['body']; item being shown when you open the email.
thanks for looking
Lee
$time = date("Y-m-d H:i:s");
$query = "SELECT * FROM email_pending WHERE subject = 'Skyways' AND status='0' ORDER BY time_inserted ASC LIMIT 45";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
if(mysql_num_rows($result) > 0) {
do {
$fileatt = "August.pdf";
$fileatttype = "application/pdf";
$fileattname = "August_Magazine.pdf";
$file = fopen( $fileatt, 'rb' );
$data = fread( $file, filesize( $fileatt ) );
fclose( $file );
$mime_boundary = md5( mt_rand() );
$data = chunk_split( base64_encode( $data ) );
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$row['body'] . "\n\n";
$headers = "From: " . $row['from'] . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
"Content-Type: {$fileatttype};\n" .
" name=\"{$fileattname}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileattname}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
" boundary=\"{$mime_boundary}\"";
mail($row['to'], $row['subject'], $message, $headers);
sleep(1);
$query1 = "UPDATE email_pending SET time_sent='$time', status='1' WHERE id='" . $row['id'] . "'";
$result1 = mysql_query($query1) or die(mysql_error());
} while($row = mysql_fetch_assoc($result));
}