Ik heb een probleem met het versturen van een mail met attachment in php. De mail wordt wel verstuurd maar nooit ontvangen, kheb de search al gebruikt maar kben niks wijzer geworden.
<?
ini_set("max_execution_time","300");
if ($action == "send")
{
$from = "$Voorletters $Naam";
$to = "mail@mail.com";
$header = "From: " . $from . "\n";
$gegevens = "Advertentie: $Advertentie\n" . "Prijs: $Prijs\n" . "Zoekwoord: $Zoekwoord\n" . "Naam: $Naam, $Voorletters\n" . "Adres: $Adresnummer\n" . "Postcode: $Postcodecijfers $Postcodeletters\n" . "Woonplaats: $Woonplaats\n" . "Email: $email\n" . "Telefoonnummer: $Telefoonnummer\n" . "Fax: $FAX";
if ($attachment != "none")
{
// Get attachment type
@$type = $HTTP_POST_FILES[attachment][type];
if (($type == "image/jpg") || ($type == "image/jpeg") || ($type == "image/gif"))
$encoding = "base64";
else
$encoding = "8bit";
// Get attachment content
$fp = @fopen($HTTP_POST_FILES[attachment][tmp_name],"r");
if (!$fp) {
print "Could not open attachment for reading...<br>\n";
print "Exiting script!<br><br>";
print "No mail has been sent!";
exit;
}
@$file_content = fread($fp,filesize($HTTP_POST_FILES[attachment][tmp_name]));
// if encoding is base64 ... encode it
if ($encoding == "base64")
$file_content = chunk_split(base64_encode($file_content));
// create a unqiue boundary
$boundary = strtoupper(md5(uniqid(time())));
// create the message header...
$header .= "MIME-version: 1.0\n";
$header .= "Content-Type: multipart/mixed;\n";
$header .= "\tboundary= " . $boundary . "\n\n";
$header .= "This is a multi-part message in MIME format.\n\n";
// create the message body in the header
$header .= "--" . $boundary . "\n";
@$header .= "Content-Type: " . $ct . ";\n";
$header .= "\tcharset=\"iso-8859-1\"\n";
$header .= "Content-Transfer-Encoding: quoted-printable\n\n";
// actual message
$header .= $gegevens . "\n\n";
// now for the attachment
$header .= "--" . $boundary . "\n";
$header .= "Content-Type: " . $type . "\n";
$header .= "Content-Transfer-Encoding: " . $encoding . "\n";
@$header .= "Content-Disposition: attachment; filename=\"" . $HTTP_POST_FILES[attachment][name] . "\"\n\n";
// actual attachment
$header .= $file_content . "\n\n";
$header .= "--" . $boundary . "--";
}
else // if there is no attachment...
{
@$header .= "Content-Type: " . $ct . ";\n";
$header .= "\tcharset=\"iso-8859-1\"\n";
$header .= "Content-Transfer-Encoding: quoted-printable\n\n";
// actual message
$header .= $gegevens . "\n\n";
}
if (@mail($to,$subject,"",$header))
print "";
else
print "Fout met het versturen van e-mail";
}
?>
alvast bedankt
<?
ini_set("max_execution_time","300");
if ($action == "send")
{
$from = "$Voorletters $Naam";
$to = "mail@mail.com";
$header = "From: " . $from . "\n";
$gegevens = "Advertentie: $Advertentie\n" . "Prijs: $Prijs\n" . "Zoekwoord: $Zoekwoord\n" . "Naam: $Naam, $Voorletters\n" . "Adres: $Adresnummer\n" . "Postcode: $Postcodecijfers $Postcodeletters\n" . "Woonplaats: $Woonplaats\n" . "Email: $email\n" . "Telefoonnummer: $Telefoonnummer\n" . "Fax: $FAX";
if ($attachment != "none")
{
// Get attachment type
@$type = $HTTP_POST_FILES[attachment][type];
if (($type == "image/jpg") || ($type == "image/jpeg") || ($type == "image/gif"))
$encoding = "base64";
else
$encoding = "8bit";
// Get attachment content
$fp = @fopen($HTTP_POST_FILES[attachment][tmp_name],"r");
if (!$fp) {
print "Could not open attachment for reading...<br>\n";
print "Exiting script!<br><br>";
print "No mail has been sent!";
exit;
}
@$file_content = fread($fp,filesize($HTTP_POST_FILES[attachment][tmp_name]));
// if encoding is base64 ... encode it
if ($encoding == "base64")
$file_content = chunk_split(base64_encode($file_content));
// create a unqiue boundary
$boundary = strtoupper(md5(uniqid(time())));
// create the message header...
$header .= "MIME-version: 1.0\n";
$header .= "Content-Type: multipart/mixed;\n";
$header .= "\tboundary= " . $boundary . "\n\n";
$header .= "This is a multi-part message in MIME format.\n\n";
// create the message body in the header
$header .= "--" . $boundary . "\n";
@$header .= "Content-Type: " . $ct . ";\n";
$header .= "\tcharset=\"iso-8859-1\"\n";
$header .= "Content-Transfer-Encoding: quoted-printable\n\n";
// actual message
$header .= $gegevens . "\n\n";
// now for the attachment
$header .= "--" . $boundary . "\n";
$header .= "Content-Type: " . $type . "\n";
$header .= "Content-Transfer-Encoding: " . $encoding . "\n";
@$header .= "Content-Disposition: attachment; filename=\"" . $HTTP_POST_FILES[attachment][name] . "\"\n\n";
// actual attachment
$header .= $file_content . "\n\n";
$header .= "--" . $boundary . "--";
}
else // if there is no attachment...
{
@$header .= "Content-Type: " . $ct . ";\n";
$header .= "\tcharset=\"iso-8859-1\"\n";
$header .= "Content-Transfer-Encoding: quoted-printable\n\n";
// actual message
$header .= $gegevens . "\n\n";
}
if (@mail($to,$subject,"",$header))
print "";
else
print "Fout met het versturen van e-mail";
}
?>
alvast bedankt