Note that there are some explanatory texts on larger screens.

plurals
  1. POStyling e-mail that is sent from a contact form
    primarykey
    data
    text
    <p>How can I style an e-mail that's sent from a contact form? </p> <p>I'd like to place it into nice tables with some decent styling. My front-end is just a HTML page that the user fills out a form. The form, upon submit, calls this PHP page to send the data. I have all of that portion working perfectly.</p> <p>Now, I'd just like to style how the e-mail looks to the person receiving the e-mail since right now it's all just text &amp; data.</p> <p>My current PHP code is:</p> <pre><code>&lt;?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "email@email.com"; $email_subject = "TEST - NO STYLE JUST DATA- Product Research Request"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.&lt;br /&gt;&lt;br /&gt;"; echo $error."&lt;br /&gt;&lt;br /&gt;"; echo "Please go back and fix these errors.&lt;br /&gt;&lt;br /&gt;"; die(); } // validation expected data exists if(!isset($_POST['ProductMgr']) || !isset($_POST['ProductDesc'])|| !isset($_POST['email'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $ProductMgr = $_POST['ProductMgr']; // required $email_from = $_POST['email']; // required $ProductDesc = $_POST['ProductDesc']; // required $ProjLaunchDate = $_POST['ProjLaunchDate']; // required $ProdCat = $_POST['ProdCat']; // required $ProdSubCat = $_POST['ProdSubCat']; // required $SuggVendor = $_POST['SuggVendor']; // required $VPartNum = $_POST['VPartNum']; // required $EstLandCost = $_POST['EstLandCost']; // required $EstRetail = $_POST['EstRetail']; // required $GMPercent = $_POST['GMPercent']; // required $GMDollar = $_POST['GMDollar']; // required $ForeUSales = $_POST['ForeUSales']; // required $ForeDSales = $_POST['ForeDSales']; // required $WholesalePot = $_POST['WholesalePot']; // required $CompProdPrice = $_POST['CompProdPrice']; // required $CompCompany = $_POST['CompCompany']; // required $SampleAvail = $_POST['SampleAvail']; // required $ProdDims = $_POST['ProdDims']; // required $ProdColors = $_POST['ProdColors']; // required $EstProdWeight = $_POST['EstProdWeight']; // required $Features = $_POST['Features']; // required $AMLBenefits = $_POST['AMLBenefits']; // required $ProBenefits = $_POST['ProBenefits']; // required $Restrictions = $_POST['Restrictions']; // required $GKS = $_POST['GKS']; $ProdMgr2 = $_POST['ProdMgr2']; // required $ProdDesc2 = $_POST['ProdDesc2']; // required $PossVend = $_POST['PossVend']; // required $ProjReTime = $_POST['ProjReTime']; // required $EstLandCost2 = $_POST['EstLandCost2']; // required $ProtoExpDate = $_POST['ProtoExpDate']; // required $ProdExpDate = $_POST['ProdExpDate']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.&lt;br /&gt;'; } if(strlen($error_message) &gt; 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Product Manager: ".clean_string($ProductMgr)."\n"; $email_message .= "Product Description: ".clean_string($ProductDesc)."\n"; $email_message .= "Projected Launch Date: ".clean_string($ProjLaunchDate)."\n"; $email_message .= "Product Category: ".clean_string($ProdCat)."\n"; $email_message .= "Product Subcategory: ".clean_string($ProdSubCat)."\n"; $email_message .= "Suggested Vendor: ".clean_string($SuggVendor)."\n"; $email_message .= "Vendor Part Number: ".clean_string($VPartNum)."\n"; $email_message .= "Estimated Landed Cost: ".clean_string($EstLandCost)."\n"; $email_message .= "Estimated Retail: ".clean_string($EstRetail)."\n"; $email_message .= "Gross Margin %: ".clean_string($GMPercent)."\n"; $email_message .= "Gross Margin $: ".clean_string($GMDollar)."\n"; $email_message .= "Forecasted Unit Sales: ".clean_string($ForeUSales)."\n"; $email_message .= "Forecasted Dollar Sales: ".clean_string($ForeDSales)."\n"; $email_message .= "Wholesale Potential: ".clean_string($WholesalePot)."\n"; $email_message .= "Competition Product &amp; Price: ".clean_string($CompProdPrice)."\n"; $email_message .= "Competitor Company: ".clean_string($CompCompany)."\n"; $email_message .= "Sample Available: ".clean_string($SampleAvail)."\n"; $email_message .= "Product Dimensions: ".clean_string($ProdDims)."\n"; $email_message .= "Product Colors: ".clean_string($ProdColors)."\n"; $email_message .= "Estimated Product Weight: ".clean_string($EstProdWeight)."\n"; $email_message .= "Features: ".clean_string($Features)."\n"; $email_message .= "Benefits to AML: ".clean_string($AMLBenefits)."\n"; $email_message .= "Benefits to Pro Customers: ".clean_string($ProBenefits)."\n"; $email_message .= "Any Restrictions: ".clean_string($Restrictions)."\n"; $email_message .= "GKS Approval To Go: ".clean_string($GKS)."\n"; $email_message .= "Product Manager: ".clean_string($ProdMgr2)."\n"; $email_message .= "Product Description: ".clean_string($ProdDesc2)."\n"; $email_message .= "Possible Vendors: ".clean_string($PossVend)."\n"; $email_message .= "Projected Research Time: ".clean_string($ProjReTime)."\n"; $email_message .= "Estimated Landing Cost: ".clean_string($EstLandCost2)."\n"; $email_message .= "Prototypes Expected Date: ".clean_string($ProtoExpDate)."\n"; $email_message .= "Production Expected Date: ".clean_string($ProdExpDate)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); } header("Location: ThankYou.html"); //Redirect to Thank You HTML page after email is sent ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload