Thank you for your response.
I am not the biggest PHP-hero, so I will just post the scipt from the book, that I have used.
<?php
function makeAttachment($attachment) {
//send content type
$headers = "Content-Type: " .$attachment["type"];
if(isset($attachment["name"])) {
$headers .= "; name =\"{$attachment["name"]}\"";
}
$headers .= "\r\n".
"Content-Transfer-Encoding: base64\r\n".
"\r\n".
chunk_split(base64_encode($attachment["content"])).
"\r\n";
return $headers;
}
function mailAttachment($to, $from, $subject, $attachment) {
//add from header
$headers = "From: $from\r\n";
//specify MIME version 1.0
$headers .= "MIME-Version: 1.0\r\n";
//multiple parts require special treatment
if(count($attachment) > 1) {
//multiple attachments require special handling
$boundary = uniqid("COREPHP");
$headers .= "Contant-Type: multipart/mixed".
"; boundary = $boundary\r\n\r\n".
"This is a MIME encoded message.\r\n\r\n".
"--$boundary";
foreach($attachment as $a) {
$headers .= "\r\n".
makeAttachment($a).
"--$boundary";
}
$headers .= "--\r\n";
} else {
$headers .= makeAttachment($attachment[0]);
}
mail($to, $subject, "", $headers);
}
//add text explaining message
$attach[] = array("content"=>"This is Listing 24-6", "type"=>"text/plain");
//add script to list of attachments
$fp = fopen("alien.jpg", "r");
$attach[] = array("name"=>basename("alien.jpg"), "content"=>fread($fp, filesize("alien.jpg")), "type"=>"application/octet-stream");
fclose($fp);
//send mail to legende
mailAttachment("jesper<at>legende.dk", "test<at>legende.dk", "Listing 24-6", $attach);
print("Mail sent!<br>\n");
?>
I hope you can tell me what's wrong. I would be ever so grateful 🙂