...

View Full Version : mail() help



SDP2006
10-28-2003, 01:06 AM
My script
<?php
$yourname = $_POST['yourname'];
$yourmail = $_POST['yourmail'];
$friendname = $_POST['friendname'];
$friendmail = $_POST['friendmail'];
$subject = "Site Recommendation from $yourname";
$mailheader = "From: $yourmail\n";
$mailheader .= "Reply-To: $yourmail\n\n";
$message = "Hi, $friendname! $yourname has recommended <a href=\"http:\\www.net-riches.com\">Net-Riches.com</a> for you to see. You can do so by clicking <a href=\"http:\\www.net-riches.com\">here</a>\n\nThank You!";
mail($friendmail,$subject,$message,$mailheader) or die("Failure!");
echo "Thanks!";
echo "<hr noshade color=\"black\" size=\"1\">";
echo "Here is what you sent :";
echo "From $yourname @ $yourmail";
echo "<br>";
echo "To $friendname @ $friendmail";
echo "<br>";
echo $message;
?>Is mailing properly except for one thing, the message is howing with <a href="http://www.net-riches.com">Net-Riches.com</a> instead of Net-Riches.com (http://www.net-riches.com) Is there a reason why?

Thanks

missing-score
10-28-2003, 02:36 AM
becuase you haven't set any kind of content type... the system assumes it is plain text without the Content-Type: header.

try adding:

Content-type: text/html;

as one of the headers. I may be slightly off but i think its something along those lines.

SDP2006
10-28-2003, 02:42 AM
<?php
$yourname = $_POST['yourname'];
$yourmail = $_POST['yourmail'];
$friendname = $_POST['friendname'];
$friendmail = $_POST['friendemail'];
$subject = "Site Recommendation from $yourname";
$mailheader = "From: $yourmail\n";
$mailheader .= "Reply-To: $yourmail\n\n";
$mailheader .= "Content-Type: text/html";
$message = "Hi, $friendname! $yourname has recommended <a href=\"http:\\www.net-riches.com\">Net-Riches.com</a> for you to see. You can do so by clicking <a href=\"http:\\www.net-riches.com\">here</a>\n\nThank You!";
mail($friendmail,$subject,$message,$mailheader) or die("Failure!");
echo "Thanks!";
echo "<hr noshade color=\"black\" size=\"1\">";
echo "Here is what you sent :";
echo "From $yourname @ $yourmail";
echo "<br>";
echo "To $friendname @ $friendmail";
echo "<br>";
echo $message;
?>Sounded reasonable, but It just displays Content-Type: text/html in the message body......

missing-score
10-28-2003, 02:47 AM
MIME-Version: 1.0\r\n
Content-Type: multipart/alternative;

that also rings a bell, try that

i seem to remember something to do with a boundry... ill try find out

SDP2006
10-28-2003, 02:53 AM
<?php
$yourname = $_POST['yourname'];
$yourmail = $_POST['yourmail'];
$friendname = $_POST['friendname'];
$friendmail = $_POST['friendemail'];
$subject = "Site Recommendation from $yourname";
$mailheader = "From: $yourmail\n";
$mailheader .= "Reply-To: $yourmail\n\n";
/*The three below right here just show up in the message body*/
$mailheader .= "MIME-Version: 1.0\r\n";
$mailheader .= "Content-Type: multipart/alternative";
$mailheader .= "Content-Type: text/html";
$message = "Hi, $friendname! $yourname has recommended <a href=\"http:\\www.net-riches.com\">Net-Riches.com</a> for you to see. You can do so by clicking <a href=\"http:\\www.net-riches.com\">here</a>\n\nThank You!";
mail($friendmail,$subject,$message,$mailheader) or die("Failure!");
echo "Thanks!";
echo "<hr noshade color=\"black\" size=\"1\">";
echo "Here is what you sent :";
echo "From $yourname @ $yourmail";
echo "<br>";
echo "To $friendname @ $friendmail";
echo "<br>";
echo $message;
?>

Read my comments

missing-score
10-28-2003, 02:56 AM
if i have got it right:




$mailheader = "From: $yourmail\n";
$mailheader .= "Reply-To: $yourmail\n";
$mailheader .= "MIME-Version: 1.0\n";
$mailheader .= "Content-Type: multipart/alternative\n";
$mailheader .= "Content-Type: text/html\n";
// need \n at the end of each line

SDP2006
10-28-2003, 03:02 AM
Nope, doesnt work........

fraknot
10-28-2003, 03:27 PM
from php.net:



<?php
/* recipients */
$to = "Mary <mary@example.com>" . ", " ; // note the comma
$to .= "Kelly <kelly@example.com>";

/* subject */
$subject = "Birthday Reminders for August";

/* message */
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n";

$headers .= "Cc: birthdayarchive@example.com\r\n";
$headers .= "Bcc: birthdaycheck@example.com\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum