Mam zrobony jeden skryp do generowania pliku xml z bazy postgres.
Składnia wygenerowanego gotowego i zapisanego na serwerze pliku wygląda podobnie do tej ponizej:
<?xml version="1.0" encoding="ISO-8859-2" ?> <data> <header> <column name="1" type="int4" /> <column name="2" type="text" /> <column name="3" type="text" /> <column name="4" type="text" /> <column name="5" type="text" /> <column name="6" type="text" /> <column name="7" type="text" /> </header> <records> <row> <column name="1">1</column> <column name="2">2</column> <column name="3">2</column> <column name="4">4</column> <column name="5">5</column> <column name="6">6</column> <column name="7">7</column> </row> </records> </data>
drugi skrypt wysyłający wysyła ten plik na wskazany adres email. Wszystko działa dobrze tylko jedno jest nie tak.
Plik który na serwerze jest poprawnym xml (kod powyżej) po przesłaniu i odebraniu a następnie otworzeniu odebranego pliku xml ma składnię podobna do ponizszej:
<?xml version=\"1.0\" encoding=\"ISO-8859-2\" ?> <data> <header> <column name=\"1\" type=\"int4\" /> <column name=\"2\" type=\"text\" /> <column name=\"3\" type=\"text\" /> <column name=\"4\" type=\"text\" /> <column name=\"5\" type=\"text\" /> <column name=\"6\" type=\"text\" /> <column name=\"7\" type=\"text\" /> </header> <records> <row> <column name=\"1\">1</column> <column name=\"2\">2</column> <column name=\"3\">2</column> <column name=\"4\">4</column> <column name=\"5\">5</column> <column name=\"6\">6</column> <column name=\"7\">7</column> </row> </records> </data>
Skryt wysyłający wygląda tak:
<?php $boundary = "-->===_53414723_===<---->>4221==_"; $header = "From: from\n"; $header = $header . "Reply-To: replyto\n"; $header = $header . "X-Mailer: PHP\n"; $header = $header . "X-Sender: from\n"; $header = $header . "MIME-version: 1.0\n"; $header = $header . "Content-type: multipart/mixed; "; $header = $header . "boundary=\"$boundary\"\n"; $header = $header . "Content-transfer-encoding: 8bit\n"; $header = $header . "X-attachments: plik.xml;\n\n"; $mesg = "--" . $boundary . "\n"; $mesg = $mesg . "Content-Type: text/plain; charset=\"iso-8859-2\"\n\n"; $mesg = $mesg . $message . "\n"; $mesg = $mesg . "--" . $boundary . "\n"; $mesg = $mesg . "Content-type: text/xml; name=\"plik.xml";\n"; $mesg = $mesg . "Content-Transfer-Encoding: base64\n"; $mesg = $mesg . "Content-disposition: attachment; filename= \"plik.xml\"\n\n"; $mesg = $mesg . encoding($filename) . "\n"; $mesg = $mesg . "--" . $boundary . "-- \n"; function encoding($file) { } return $encoded; } ?>
Co zrobić żeby mail plik był wysłany w formacie takim jak jest na serwerze a nie przetworzony i przed " jest wstawione \.