This is a discussion on "Form2Email build message with html, I need help" within the PHP Forum section. This forum, and the thread "Form2Email build message with html, I need help are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Form2Email build message with html, I need help
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
I dont know what I need to do to create a section of writing to be sent with html. I have highlight what I would like to retain its html, and I would like to know what I need to do
// Build message. function build_message($request_input){if(!isset($message_o utput)){$message_output = "";}if(!is_array($request_input)){$message_out put = $request_input;}else{foreach($request_input as $key => $value){if(!is_numeric($key)){$message_output .= "\n\n".$key.": ".build_message($value);}else{$message_output .= "\n\n".build_message($value);}}}return $message_output;} $message = $message . "Hello "; $message = $message . $_POST['nameto']; $message = $message . "<p>At Poetry Australia we are dedicated to serving the craft of the Poet. </p> <p>Our charter is the Promotion, Development and Tutoring of this fine art and our primary intention is to use this most elegant of skills for the betterment of humankind. In particular we seek to highlight the many beauties, freedoms, and virtues of this vast and wondrous land in which we live. </p> <p>Those of our society that are given to a deeper understanding of life will know that the optimum advancement of humankind is to stand as a union of peoples without such things as national boundaries. As we find, however, that such things are necessary at this stage of our human evolution, it is our imperative to, at least, be proud of who and what we are and what it is that we come to stand for, yet without proving arrogant. </p> <p> . . . </p> <p align=center>FOR Australia – OF Australia – BY Australia.</p> <p align=center>--</p> <p align=center>An Island of Peace In A World of Anger.</p> <p></p>"; $message = stripslashes($message); $subject = "New Membership Info"; $headers = "From: " . $form_input['email'] . "\n" . "Return-Path: " . $form_input['email'] . "\n" . "Reply-To: " . $form_input['email'] . "\n"; mail($my_email,$subject,$message,$headers); ?> _________________________________________________ This is what the email looks like; Hello Michael<p>At Poetry Australia we are dedicated to serving the craft of the Poet. </p> <p>Our charter is the Promotion, Development and Tutoring of this fine art and our primary expression in our core contributions will be . . . </p> <p align=center>FOR Australia – OF Australia – BY Australia.</p> <p align=center>--</p> <p align=center>An Island of Peace In A World of Anger.</p> <p>We have well noted that there are few opportunities for them the availability of making profits : without payment, acknowledgement or expression of thanks to the selected authors. The hope-filled Poets, then, becoming a source of free labour. </p> |
|
|
|
|||
|
Re: Form2Email build message with html, I need help
You need to add a content-type header to let the receiving email client know that's it's not receiving plain text. For example:
![]() ![]() For a longer term / more thorough fix, I would suggest that you might also want to have a look at multipart emailing (emailing with enclosures) so that you can send both the HTML for people who can read it, and plain text for those who cannot or choose not to. You may also want to look at how "spammy" the emails look - my spamassassin rated the two very differently, though correctly recognised that both were superb emails that should not be assigned to my waste basket. |
|
|||
|
This is the first time I have built a message like this, and I am very new to this, and none of the ways I used your script worked or did any thing.
I am unsure how to use: $message . = "Content-type: text/html\n"; and I don’t know what EMC is, and I don’t know how to incorporate $extras . in to my message. I just found this script somewhere. Sorry I would like to continue this |
|
|||
|
Re: Form2Email build message with html, I need help
The "EMC" stuff was just a quick way of me putting a message together - it's cleaner that the multiline double quotes in your example IMHO - that's all.
A "quick" answer would be for you to simple add $headers .= "Content-type: text/html\n"; just before the mail line and that should get you sorted. But there's a lot to PHP and if this stuff is all pretty new, some of the tutorials that are around should help. Learning the whole thing by "question / answer" on a forum isn't practical - though it's a darned good way of sorting out issues that arise. |
|
|||
|
Re: Form2Email build message with html, I need help
I looked for a tutorial or script that would give me the code for how to add html to be sent from a for but did not find any
Yeah this is my issue at the moment I don’t want to bother anyone, I have successfully modified all kinds of scripts with out asking any question, and this is only the second question I have asked relating to PHP, I thought it would be a simple bit of code to get this sorted but it dose not look like it, Anyway when I use $headers .= "Content-type: text/html\n"; I get this error; Parse error: syntax error, unexpected T_NEW in /home/seehereo/public_html/poetryaustralia/tellafriend/FormToEmail.php on line 203 Line 203: $subject = "test form"; Line 204: Line 205: $headers = "From: " . $form_input['email'] . "\n" . "Return-Path: " . $form_input['email'] . "\n" . "Reply-To: " . $form_input['email'] . "\n"; __________________________________________________ _____ |
|
|||
|
Re: Form2Email build message with html, I need help
This is my hole script:
<?php /* Thank you for choosing FormToEmail by FormToEmail.com Version 1.9 December 31st 2006 COPYRIGHT FormToEmail.com 2003 - 2006 SETUP INSTRUCTIONS Step 1: Put the form on your webpage Step 2: Enter your email address and continue link below Step 3: Upload the files to your webspace Step 1: To put the form on your webpage, copy the code below as it is, and paste it into your webpage: Step 2: Enter your email address. Enter the email address below to send the contents of the form to. You can enter more than one email address separated by commas, like so: $my_email = "xxxxxxxxx"; */ $my_email = $_POST['emailto']; /* Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage. If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm" */ $continue = "https://www.x"; /* Step 3: Save this file (FormToEmail.php) and upload it together with your webpage to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above! Do not put this script in your cgi-bin directory (folder) it may not work from there. THAT'S IT, FINISHED! You do not need to make any changes below this line. */ // Initialise variables $errors = array(); if($_SERVER['REQUEST_METHOD'] == "POST"){$form_input = $_POST;}elseif($_SERVER['REQUEST_METHOD'] == "GET"){$form_input = $_GET;}else{exit;} // Remove leading whitespace from all values. function recursive_array_check(&$element_value) { if(!is_array($element_value)){$element_value = ltrim($element_value);} else { foreach($element_value as $key => $value){$element_value[$key] = recursive_array_check($value);} } return $element_value; } recursive_array_check($form_input); // Check referrer is from same site. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} // Check for a blank form. function recursive_array_check_blank($element_value) { global $set; if(!is_array($element_value)){if(!empty($element_v alue)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} } } recursive_array_check_blank($form_input); if(!$set){$errors[] = "You cannot send a blank form";} // Strip HTML tags from all fields. function recursive_array_check2(&$element_value) { if(!is_array($element_value)){$element_value = strip_tags($element_value);} else { foreach($element_value as $key => $value){$element_value[$key] = recursive_array_check2($value);} } return $element_value; } recursive_array_check2($form_input); // Validate name field. if(isset($form_input['name']) && !empty($form_input['name'])) { if(preg_match("`[\r\n]`",$form_input['name'])){$errors[] = "You have submitted an invalid new line character";} if(preg_match("/[^a-z' -]/i",stripslashes($form_input['name']))){$errors[] = "You have submitted an invalid character in the name field";} } // Validate email field. if(isset($form_input['email']) && !empty($form_input['email'])) { if(preg_match("`[\r\n]`",$form_input['email'])){$errors[] = "You have submitted an invalid new line character";} if(!preg_match('/^([a-z][a-z0-9_.-\/\%]*@[^\s\"\)\?<>]+\.[a-z]{2,6})$/i',$form_input['email'])){$errors[] = "Email address is invalid";} } // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} // Build message. function build_message($request_input){if(!isset($message_o utput)){$message_output = "";}if(!is_array($request_input)){$message_out put = $request_input;}else{foreach($request_input as $key => $value){if(!is_numeric($key)){$message_output .= "\n\n".$key.": ".build_message($value);}else{$message_output .= "\n\n".build_message($value);}}}return $message_output;} $message = $message . "Hello "; $message = $message . $_POST['nameto']; $headers .= "Content-type: text/html\n"; $message = $message . "<p> example text -- At Poetry Australia we are dedicated to serving the craft of the Poet. </p> <p>Our charter is the Promotion, Development and Tutoring of this fine art and our primary intention is to use this most elegant of skills for the betterment of humankind. In particular we seek to highlight the many beauties, freedoms, and virtues of this vast and wondrous land in which we live. </p> <p>Those of our society that are given to a deeper understanding of life will know that the optimum advancement of humankind is to stand as a union of peoples without such things as national boundaries. As we find, however, that such things are necessary at this stage of our human evolution, it is our imperative to, at least, be proud of who and what we are and what it is that we come to stand for, yet without proving arrogant. </p> <p>As a nation we stand as a potpourri of peoples from every nation, culture, creed and multiplicity of the entirety of this world and, somehow, we are now drawn together as a collective of peoples who seek to stand as one. Those who are well travelled will readily understand that this majestic place, which we are privileged to call home, is tantamount to the Land of the New Jerusalem. </p> $message = stripslashes($message); $subject = "test form"; $headers = "From: " . $form_input['email'] . "\n" . "Return-Path: " . $form_input['email'] . "\n" . "Reply-To: " . $form_input['email'] . "\n"; mail($my_email,$subject,$message,$headers); ?> |
|
|||
|
Re: Form2Email build message with html, I need help
Continued
?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Information Sent </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="refresh" content="0; url=https://www.x"> </head> <body bgcolor="#ffffff" text="#000000"> <div> <center> <b>Thank you <?php print stripslashes($form_input['name']); ?></b> <br> <p><a href="<?php print $continue; ?>">If you are not redirected in 10 seconds please click here</a></p> <p><b></b> </a></p> </center> </div> </body> </html> |
|
|||
|
Re: Form2Email build message with html, I need help
Perhaps this code would be easier to see how I could to add a html section in to it?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sendemail Script</title> </head> <body> <!-- Reminder: Add the link for the 'next page' (at the bottom) --> <!-- Reminder: Change 'YourEmail' to Your real email --> <?php if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; } if(empty($visitor) || empty($visitormail) || empty($notes )) { echo "<h2>Use Back - fill in all fields</h2>\n"; } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $visitormail\r\n"; mail("YourEmail", $subject, $message, $from); ?> |
|
|||
|
Re: Form2Email build message with html, I need help
I found a form builder that enters in the html for you so I dont need an answer anymore, but thank you
Looks something like $confEmailBody = chunk_split(base64_encode("<HTML>\n" . "<head>\n" . "<style type=\"text/css\">\n" . " font-family: Arial;\n" . " font-size: 11px;\n" . "}\n" . ".style4 {font-size: 11px}\n" . "-->\n" . "</style>\n" . "<title></title>\n" . "</head>\n" . "<body>\n" . "<span class=\"style1\">Dear $FTGname<br />\n" . "<br />\n" . "Thank you, your Timesheet has been submitted successfully.<br />\n" . "<br />\n" . "Regards,<br />\n" . "</span><span class=\"style4\"><br />\n" . "</span>\n" . "<p class=\"style4\"><font face=\"Arial\">Max Bish</font><font face=\"Times New Roman\"><span \n" . "<div></div>\n" . "<p></p>\n" . "</body>\n" . "</html>")) . "\n"; |
![]() |
| Tags |
| build message html, php html input |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Searching tutorial on html editing to build website | satimis | Web Page Design | 14 | Mar 3rd, 2008 16:54 |
| Build A Product Catalogue on Existing HTML / CSS Based Site? | thebagman | E-Commerce and Business | 1 | Dec 15th, 2007 18:34 |
| Can you build a web page? | vitsyk | Job Opportunities | 3 | Nov 29th, 2007 00:36 |
| Need help sending HTML message in PHP. | annawilsonz | PHP Forum | 0 | Sep 14th, 2007 06:31 |
| Build my webiste! | buildmysitenow | Job Opportunities | 0 | Aug 23rd, 2007 20:58 |