designaire Posted March 4, 2008 Share Posted March 4, 2008 Hi, I'm trying to format an email sent through a php form with using html to format the message. According to what I've read, I use the following $header code. I tryed to use the following code for the message as a test which is from the php.net website. It doesn't work, however. Can anybody tell me what I'm doing wrong or why it might not be working? It's right off the php.net website. <?php //create short variable names $toaddress = '[email protected]'; $subject = 'test'; $mailcontent = '<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> '; $fromaddress = 'From: [email protected]; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($toaddress, $subject, $mailcontent, $fromaddress, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/94380-email-form-html/ Share on other sites More sharing options...
uniflare Posted March 5, 2008 Share Posted March 5, 2008 um, what error does it give, if any? is it on a local server? do you have an smtp server installed? the code looks fine. Link to comment https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-483423 Share on other sites More sharing options...
jedney Posted March 5, 2008 Share Posted March 5, 2008 Yes, offer some errors; your code is good. Link to comment https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-483433 Share on other sites More sharing options...
designaire Posted March 5, 2008 Author Share Posted March 5, 2008 No errors, it just give me the tags when I get my email. <head> <title>Birthday Reminders for August</title> </head> <body>....etc Link to comment https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-483879 Share on other sites More sharing options...
designaire Posted March 5, 2008 Author Share Posted March 5, 2008 do you have an smtp server installed? What is smtp? It need to be installed on the server? Maybe that's the problem Link to comment https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-483882 Share on other sites More sharing options...
uniflare Posted March 5, 2008 Share Posted March 5, 2008 ok if you reciev the email at all then smtp is setup correctly. If you are saying when you get the email you can see all the html tags, then the email is being sent as a plain text. - Check your headers. // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; http://uk.php.net/manual/en/function.mail.php from wat i can see there are no problems in the script, try emailing different addresses, try the email without the <html> and <head> and <body> tags, eg: <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> hope this helps, Link to comment https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-483895 Share on other sites More sharing options...
designaire Posted March 5, 2008 Author Share Posted March 5, 2008 It's a mystery. Link to comment https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-483942 Share on other sites More sharing options...
designaire Posted March 5, 2008 Author Share Posted March 5, 2008 I figured it out, I had 5 parameters instead of 4...it works now. <?php $name=$_POST['name']; $work=$_POST['work']; $toaddress = '[email protected]'; $subject = 'test'; $message =' <head> <title>Untitled Document</title> </head> <body> My name is '.$name.' and I do '.$work.' in my feild. </body> '; $headers='MIME-Version: 1.0'."\r\n"; $headers.='Content-Type: text/html; charset=iso-8859-1'."\r\n"; $headers.="From: <xxx@xxxcom>". "\r\n"; mail($toaddress, $subject, $message, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/94380-email-form-html/#findComment-484175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.