Hi all,
I have just bought the book beginning apache, php, mysql web development....I am working my way through the book but i am having trouble with chapter 10, multipart messages...I am getting an error message when i try to send the e-mail...here is the code..
this is postcard.php
<html>
<head>
<title>Enter Data</title>
</head>
<body>
<form name="theform" method="post" action="pc_sendmail.php">
<table>
<tr>
<td>To:</td>
<td><input type="text" name="to" size="50"></td>
</tr>
<tr>
<td>From:</td>
<td>
<input type="text" name="from" size="50">
</td>
</tr>
<tr>
<td>CC:</td>
<td>
<input type="text" name="cc" size="50">
</td>
</tr>
<tr>
<td>Bcc:</td>
<td><input type="text" name="bcc" size="50"></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject" size="50"></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td>
<textarea cols="60" rows="10" name="message">Enter your message here</textarea>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Send">
<input type="reset" value="Reset the form">
</td>
</tr>
</table>
</form>
</body>
</html>
and this is pc_sendmail.php
<html>
<head>
<title>Multipart Mail Sent!</title>
</head>
<body>
<?php
$to = $_POST["to"];
$cc = $_POST["cc"];
$bcc = $_POST["bcc"];
$from = $_POST["from"];
$subject = $_POST["subject"];
$messagebody = $_POST["message"];
$boundary = "==MP_Bound_xyccr948x==";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: multipart/alternative; boundary=\"$boundary\"\r\n";
$headers .= "CC: " . $cc . "\r\n";
$headers .= "BCC: " . $bcc . "\r\n";
$headers .= "From: " . $from . "\r\n";
$message = "This is a Multipart Message in MIME format\n";
$message .= "--$boundary\n";
$message .= "Content-type: text/html; charset=iso-8859-1\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= $messagebody . "\n";
$message .= "--$boundary\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= $messagebody . "\n";
$message .= "--$boundary--";
$mailsent = mail($to, $subject, $message, $headers);
if ($mailsent) {
echo "Congrats! The following message has been sent: <br><br>";
echo "<b>To:</b> $to<br>";
echo "<b>From:</b> $from<br>";
echo "<b>Subject:</b> $subject<br>";
echo "<b>Message:</b><br>";
echo $message;
} else {
echo "There was an error...";
}
?>
</body>
</html>
and this is the error message i'm gettin...
Warning: mail(): SMTP server response: 553 malformed address: <> in c:\inetpub\wwwroot\pc_sendmail.php on line 29
There was an error...
I can,t understand as I am using the exact code thats in the book and it still does not work....can anyone shed some light on this problem....
Thanks in advance
Rgds
Niall