: Hello,
:
: I have a form and i set this data into a XML file.
: Now i want to sent this file as attachment to my e-mail adres.
:
: But how can i do this?
:
: Regards en thanks,
I haven't tested this but it should get you on the right track. Google "php mail attachment" and you can probably find plenty of info.
function sendAttachment($to, $from, $subject, $message, $path_to_attachment, $filename, $MIME_type)
{
/* do error checking here to make sure file exists, is readable, ... */
$full_path = "$path_to_attachment/$filename";
$size = filesize($full_path);
$attachment = chunk_split(base64_encode(file_get_contents($full_path)));
$boundary = uniqid();
/* do input cleaning here to make sure nobody's attempting a header injection */
/* send the message */
$headers = array();
$headers[] = "From: $from\n";
$headers[] = "Content-Type: multipart/mixed; boundary=\"$uid\"\n\n";
$headers[] = "This is a multi-part message in MIME format.\n";
$headers[] = "--$boundary\n";
$headers[] = "Content-Type: text/plain; charset=iso-8859-1\n";
$headers[] = "Content-Transfer-Encoding: 7bit\n\n";
$headers[] = "$message\r\n\r\n";
$headers[] = "--$uid\n";
$headers[] = "Content-Type: $MIME_type; name=\"$filename\"\n";
$headers[] = "Content-Transfer-Encoding: base64\r\n";
$headers[] = "Content-Disposition: attachment; filename=\"$filename\"\n\n";
$headers[] = "$content\n\n";
$headers[] = "--$uid--";
$header = implode('', $headers);
/* add pass/fail checks here too */
mail($to, $subject, "", $header);
}