Не удается получить вложение xml в письме

У меня есть выходной файл xml, этот файл создается с помощью PHP Array. Я отправляю xml-файл как вложение электронной почты автоматически, используя PHP.

Теперь у меня есть приложение для планшета, это приложение получает, считывает и отображает вывод файла xml из вложения электронной почты. (Примечание: у меня нет внутреннего доступа к коду этого приложения).

Но, к сожалению, я не получил XML-файл в приложении планшета (который я создал через PHP), который я отправил в электронном письме.

Как это исправить? спасибо

У меня такие ошибки:

Warning: filesize() [function.filesize]: on line 20 Warning: fopen(/usr/local/apache/htdocs/Test/filename.xml) [function.fopen]: on line 21 Warning: fread(): supplied argument is not a valid stream resource on line 22 Warning: fclose(): supplied argument is not a valid stream resource on line 23 

Примечание. Неопределенная переменная: message_body в /home7/homecre1/public_html/Test/Mail.php в строке 47 Отправлено

Вот Mail PHP

 <?php /* Email Detials */ $mail_to = ""; $from_mail = ""; $from_name = "Test"; $reply_to = ""; $subject = "Test only"; $message = ""; /* Attachment File Attachment location */ $file_name = "filename.xml"; $path = "www.domainname.com/folder/folder/"; // Read the file content $file = $path.$file_name; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); /* Set the email header Generate a boundary */ $boundary = md5(uniqid(time())); // Email header $header = "From: ".$from_name." \r\n"; $header .= "Reply-To: ".$reply_to."\r\n"; $header .= "MIME-Version: 1.0\r\n"; // Multipart wraps the Email Content and Attachment $header .= "Content-Type: multipart/mixed;\r\n"; $header .= " boundary=\"".$boundary."\""; $message .= "This is a multi-part message in MIME format.\r\n\r\n"; $message .= "--".$boundary."\r\n"; /* Email content Content-type can be text/plain or text/html */ $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $message .= "Content-Transfer-Encoding: 7bit\r\n"; $message .= "\r\n"; $message .= "$message_body\r\n"; $message .= "--".$boundary."\r\n"; /* Attachment Edit content type for different file extensions */ $message .= "Content-Type: application/xml;\r\n"; $message .= " name=\"".$file_name."\"\r\n"; $message .= "Content-Transfer-Encoding: base64\r\n"; $message .= "Content-Disposition: attachment;\r\n"; $message .= " filename=\"".$file_name."\"\r\n"; $message .= "\r\n".$content."\r\n"; $message .= "--".$boundary."--\r\n"; // Send email if (mail($mail_to, $subject, $message, $header)) { echo "Sent"; } else { echo "Error"; } ?> 

PHP-массив для xml

 <?php header('Content-Type: text/xml'); $xml_Form = new SimpleXMLElement("<?xml version=\"1.0\"?><Form></Form>"); $xml_Form->addAttribute('label', 'Home Visit Form'); $Fields= $xml_Form->addChild('Field'); $Fields->addAttribute('name', 'CP_REASON_CODE'); $Fields->addAttribute('label', 'Reason Code'); $Fields->addAttribute('value', ''); $Fields->addAttribute('type', 'EditText'); $Fields->addAttribute('format', 'string'); $Fields= $xml_Form->addChild('Field'); $Fields->addAttribute('name', 'CP_NOTES'); $Fields->addAttribute('label', 'Notes'); $Fields->addAttribute('value', ''); $Fields->addAttribute('type', 'EditText'); $Fields->addAttribute('format', 'string'); $Fields= $xml_Form->addChild('Field'); $Fields->addAttribute('name', 'CP_PICTURE_RECEIPT'); $Fields->addAttribute('label', 'Receipt picture'); $Fields->addAttribute('value', ''); $Fields->addAttribute('type', 'Picture'); $Fields->addAttribute('format', 'string'); $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($xml_Form->asXML()); //Echo XML - remove this and following line if echo not desired echo $dom->saveXML(); //Save XML to file - remove this and following line if save not desired $dom->save('CashPickup.xml'); ?>