Jump to content

displaying html coding in email


partha

Recommended Posts

<html><body><?phpfunction spamcheck($field) {//eregi() performs a case insensitive regular expression match if(eregi("to:",$field) || eregi("cc:",$field)) { return TRUE; } else { return FALSE; } }//if "email" is filled out, send emailif (isset($_REQUEST['email'])) { //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); if ($mailcheck==TRUE) { echo "Invalid input"; } else { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = "<table border=1><tr><td>" . $_REQUEST['message'] . "</td></tr></table>"; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; $headers .= "From: $_SERVER[HTTP_POST] <$email>\n"; $headers .= "X-Priority: 1\n"; $headers .= "X-MSMail-Priority: High\n"; $headers .= "X-Mailer: PHP/" . phpversion()."\n"; mail("partha@cachegroups.com", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; } }else//if "email" is not filled out, display the form { echo "<form method='post' action='testemail.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; }?></body></html>

Link to comment
Share on other sites

<?php/* recipients */$to = "mary@example.com" . ", " ; // note the comma$to .= "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 .= "To: Mary <mary@example.com>, Kelly <kelly@example.com>\r\n";$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);?> this is the example mail coding check this it is working properly.and go to this url there down load the manualhttp://in2.php.net/get/php_manual_en.chm/from/a/mirrorit is very help ful.

Link to comment
Share on other sites

  • 2 weeks later...
$headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n";$headers .= "Content-Transfer-Encoding: 8bit\n"; $headers .= "From: $_SERVER[HTTP_POST] <$email>\n"; $headers .= "X-Priority: 1\n"; $headers .= "X-MSMail-Priority: High\n"; $headers .= "X-Mailer: PHP/" . phpversion()."\n";

The problem is probably that your headers are ending with \n. Headers should end with \r\n.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...