设置从联系人表单发送的电子邮件的样式



如何对从联系人表单发送的电子邮件进行样式设置?

我想把它放在造型得体的漂亮桌子上。我的前端只是一个HTML页面,用户填写表单。表单在提交时会调用这个PHP页面来发送数据。我把这部分都做好了。

现在,我只想设计一下电子邮件对接收电子邮件的人来说是什么样子的,因为现在它只是文本&数据

我目前的PHP代码是:

<?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.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    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.<br />';
  }
  if(strlen($error_message) > 0) {
died($error_message);
  }
        $email_message = "Form details below.nn";
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 & 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."rn".
'Reply-To: '.$email_from."rn" .
'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
?>

消息正文的开头以以下代码行开头:

$email_message="下面的表单详细信息。\n\n";

然后,消息的其余部分只是以"label:$value"的格式在新行中添加每个值,以:开头

$email_message.=产品经理:".clean_string($ProductMgr(。"\n";

以结束

$email_message.="生产预期日期:".clean_string($ProdExpDate(。"\n";

假设您希望将所有这些都放在一个表中,您可以在字段分配之前或之后添加一行,或者将其前置/附加到上面的语句中。一个非常基本的例子:

$email_message .="<table>";
$email_message .= "Product Manager: ".clean_string($ProductMgr)."n";
.
.
.
$email_message .= "Production Expected Date: ".clean_string($ProdExpDate)."n";
$email_message .= "</table>";

根据需要添加页眉、行和列,以获得您想要的布局(如果您希望使用表路由(。

基本上,您只是将html添加到$email_message中。您可能会发现先让html工作更容易,然后将其用作连接$email_message字符串以获得相同结果的模板。

祝你好运。

相关内容

  • 没有找到相关文章

最新更新