php mail sends the mail but body is not visiable
Posted: Thu Mar 15, 2007 1:43 pm
Below is the source of an email, the way mozilla mail shows it. But the body of the mail is not visiable in the normal way. So, if I start mozilla mail and check for new mail, I see the header and below that its blank. Only when I click "view source" I get this:
The code to produce this mail is:
The mail source and php code contain 'mydomain' and 'somedomain'. In real the right domain names are filled in here.
Things become even stranger when I use my ISP webmail service. Then the mail body is shown. Can somebody point out what is going wrong here?
Thanks.
Code: Select all
From - Thu Mar 15 19:18:14 2007
X-UIDL: 1173982686._smtp.mxdrop29.16846,S=3017
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <anonymous@somedomain>
Received: from ns1.somedomain(
Received: (qmail 387 invoked by uid 48); 15 Mar 2007 19:18:04 +0100
Date: 15 Mar 2007 19:18:04 +0100
Message-ID: <20070315181804.386.qmail@somedomain>
To: colweb@xs4all.nl
Subject: Test HTML email
From: website@mydomain
Reply-To: webmaster@mydomain
Content-Type: multipart/alternative; boundary="PHP-alt-9b219c8fff7fe3cfea4f4a8b88470cb6"
X-XS4ALL-DNSBL-Checked: mxdrop29.xs4all.nl checked 62.148.174.180 against DNS blacklists
X-Virus-Scanned: by XS4ALL Virus Scanner
X-XS4ALL-Spam-Score: 0.6 () DK_POLICY_SIGNSOME,HTML_MESSAGE,MIME_HEADER_CTYPE_ONLY,NO_REAL_NAME
X-XS4ALL-Spam: NO
Envelope-To: colweb@xs4all.nl
X-UIDL: 1173982686._smtp.mxdrop29.16846,S=3017
--PHP-alt-9b219c8fff7fe3cfea4f4a8b88470cb6
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Bestelling VVV Actief Gids en/of Kaart.
Uw naam:
Adres:
Postcode:
Plaats:
e-mail adres:
VVV Actief gids, aantal: 1 - prijs: 1.00
VVV Actief kaart, aantal: 1 - prijs: 1.00
Sub totaal.........................: 2.00
Korting............................: 0.50
Verzend en administratie kosten....: 2.50
Totaal.............................: 4.00
Bedankt voor uw bestelling. Levertijd is circa 2 werkdagen.
--PHP-alt-9b219c8fff7fe3cfea4f4a8b88470cb6
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
<html>
<head></head>
<body>
<table border="1" cellpadding="3" cellspacing="3">
<tr><td colspan="5"><center>Bestelling VVV Actief Gids en/of Kaart</center></td></tr>
<tr><td rowspan="8" style="vertical-align: top;">
<table border="0" cellpadding="0" cellspacing="3">
<tr><td>Uw naam:</td><td></td></tr>
<tr><td>Adres:</td><td></td></tr>
<tr><td>Postcode:</td><td></td></tr>
<tr><td>Plaats:</td><td></td></tr>
<tr><td>e-mail adres:</td><td></td></tr>
</table>
</td></tr>
<tr><th>Produkt</th><th>Prijs</th><th>Aantal</th><th>Totaal</th></tr>
<tr><td>VVV Actief gids</td><td>€ 1,00 </td><td>1</td><td>1.00</td></tr>
<tr><td>VVV Actief kaart</td><td>€ 1,00 </td><td>1</td><td>1.00</td></tr>
<tr><td colspan="3" align="right">Sub totaal: € </td><td>2.00</td></tr>
<tr><td colspan="3" align="right">Korting: € </td><td>0.50</td></tr>
<tr><td colspan="3" align="right">Verzend en administratie kosten: € </td><td>2.50</td></tr>
<tr><td colspan="3" align="right">Totaal: € </td><td>4.00</td></tr>
<tr><td colspan="5" align="center">Bedankt voor uw bestelling. Levertijd is circa 2 werkdagen.</td></tr>
</table>
</body>
</html>
--PHP-alt-9b219c8fff7fe3cfea4f4a8b88470cb6--
--PHP-alt-9b219c8fff7fe3cfea4f4a8b88470cb6--Code: Select all
<?php
$naam = $_POST['naam'];
$adres = $_POST['adres'];
$pcode = $_POST['pcode'];
$plaats = $_POST['plaats'];
$email = $_POST['email'];
$gids_aantal = $_POST['gids_aantal'];
$gids_totaal = $_POST['gids_totaal'];
$kaart_aantal = $_POST['kaart_aantal'];
$kaart_totaal = $_POST['kaart_totaal'];
$sub_tot = $_POST['sub_tot'];
$korting = $_POST['korting'];
$verzend = $_POST['verzend'];
$totaal = $_POST['totaal'];
//define the receiver of the email
$to = 'colweb@xs4all.nl';
//define the subject of the email
$subject = 'Test HTML email';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: website@mydomain\r\nReply-To: webmaster@mydomain";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Bestelling VVV Actief Gids en/of Kaart.
Uw naam: <?php echo "$naam\r\n"; ?>
Adres: <?php echo "$adres\r\n"; ?>
Postcode: <?php echo "$pcode\r\n"; ?>
Plaats: <?php echo "$plaats\r\n"; ?>
e-mail adres: <?php echo "$email\r\n"; ?>
VVV Actief gids, aantal: <?php echo $gids_aantal; ?> - prijs: <?php echo "$gids_totaal\r\n"; ?>
VVV Actief kaart, aantal: <?php echo $kaart_aantal; ?> - prijs: <?php echo "$kaart_totaal\r\n"; ?>
Sub totaal.........................: <?php echo "$sub_tot\r\n"; ?>
Korting............................: <?php echo "$korting\r\n"; ?>
Verzend en administratie kosten....: <?php echo "$verzend\r\n" ?>
Totaal.............................: <?php echo "$totaal\r\n" ?>
Bedankt voor uw bestelling. Levertijd is circa 2 werkdagen.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
<html>
<head></head>
<body>
<table border="1" cellpadding="3" cellspacing="3">
<tr><td colspan="5"><center>Bestelling VVV Actief Gids en/of Kaart</center></td></tr>
<tr><td rowspan="8" style="vertical-align: top;">
<table border="0" cellpadding="0" cellspacing="3">
<tr><td>Uw naam:</td><td><?php echo $naam; ?></td></tr>
<tr><td>Adres:</td><td><?php echo$adres; ?></td></tr>
<tr><td>Postcode:</td><td><?php echo $pcode; ?></td></tr>
<tr><td>Plaats:</td><td><?php echo $plaats; ?></td></tr>
<tr><td>e-mail adres:</td><td><?php echo $email; ?></td></tr>
</table>
</td></tr>
<tr><th>Produkt</th><th>Prijs</th><th>Aantal</th><th>Totaal</th></tr>
<tr><td>VVV Actief gids</td><td>€ 1,00 </td><td><?php echo $gids_aantal; ?></td><td><?php echo $gids_totaal; ?></td></tr>
<tr><td>VVV Actief kaart</td><td>€ 1,00 </td><td><?php echo $kaart_aantal; ?></td><td><?php echo $kaart_totaal ?></td></tr>
<tr><td colspan="3" align="right">Sub totaal: € </td><td><?php echo $sub_tot; ?></td></tr>
<tr><td colspan="3" align="right">Korting: € </td><td><?php echo $korting ?></td></tr>
<tr><td colspan="3" align="right">Verzend en administratie kosten: € </td><td><?php echo $verzend; ?></td></tr>
<tr><td colspan="3" align="right">Totaal: € </td><td><?php echo $totaal; ?></td></tr>
<tr><td colspan="5" align="center">Bedankt voor uw bestelling. Levertijd is circa 2 werkdagen.</td></tr>
</table>
</body>
</html>
--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>Things become even stranger when I use my ISP webmail service. Then the mail body is shown. Can somebody point out what is going wrong here?
Thanks.