我正在使用我已经回收了一段时间的代码。对不起,如果它完全过时或错误。我从教程中复制了它,它始终有效。
我的客户希望将邮件正文标记设为粗体,并在动态添加的电子邮件主题中包含发件人姓名。
<?php
if ($_POST["submit"]) {
$recipient = "<!--EMAIL ADDRESS HERE-->";
$subject = "<!--SUBJECT HERE PLUS DYNAMIC NAME-->";
$sender = $_POST["name"];
$senderEmail = $_POST["email"];
$infantskidate = $_POST["infant-ski-date"];
$infantquantity = $_POST["infant-quantity"];
$infantdays = $_POST["infant-days"];
$infantinsurance = $_POST["infant-insurance"];
$childskidate = $_POST["child-ski-date"];
$childquantity = $_POST["child-quantity"];
$childdays = $_POST["child-days"];
$childinsurance = $_POST["child-insurance"];
$adultskidate = $_POST["adult-ski-date"];
$adultquantity = $_POST["adult-quantity"];
$adultdays = $_POST["adult-days"];
$adultinsurance = $_POST["adult-insurance"];
$oapskidate = $_POST["oap-ski-date"];
$oapquantity = $_POST["oap-quantity"];
$oapdays = $_POST["oap-days"];
$oapinsurance = $_POST["oap-insurance"];
$oldskidate = $_POST["old-ski-date"];
$oldquantity = $_POST["old-quantity"];
$olddays = $_POST["old-days"];
$oldinsurance = $_POST["old-insurance"];
$familyskidate = $_POST["family-ski-date"];
$familyquantity = $_POST["family-quantity"];
$familydays = $_POST["family-days"];
$familyinsurance = $_POST["family-insurance"];
$familysurname = $_POST["family-name"];
$familyage = $_POST["family-ages"];
$mailBody = "
<!--MAKE THIS BOLD-->Name:<!--ENDS BOLD--> $title $sender\n
Email: $senderEmail\n
Infant:\n
First Skiing Date: $infantskidate\n
Quantity: $infantquantity\n
No. of Days: $infantdays\n
Insurance: $infantinsurance\n\n
Child:\n
First Skiing Date: $childskidate\n
Quantity: $childquantity\n
No. of Days: $childdays\n
Insurance: $childinsurance\n\n
Adult:\n
First Skiing Date: $adultskidate\n
Quantity: $adultquantity\n
No. of Days: $adultdays\n
Insurance: $adultinsurance\n\n
65 to 74:\n
First Skiing Date: $oapskidate\n
Quantity: $oapquantity\n
No. of Days: $oapdays\n
Insurance: $oapinsurance\n\n
75+:\n
First Skiing Date: $oldskidate\n
Quantity: $oldquantity\n
No. of Days: $olddays\n
Insurance: $oldinsurance\n\n
Family:\n
First Skiing Date: $familyskidate\n
Quantity: $familyquantity\n
No. of Days: $familydays\n
Insurance: $familyinsurance\n
Family Name: $familysurname\n
Ages of Children: $familyage\n\n
";
mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");
$thankYou = "<p class='thankyou'>Thank you for submitting you order. We will get back to you shortly with payment details.</p>";
}
?>
任何帮助都会很棒。
答案 0 :(得分:3)
直接在php中使用html,然后像这样添加html邮件头;
<?php
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: $sender <$senderEmail>\r\n";
mail($recipient, $subject, $mailBody, $headers);
答案 1 :(得分:1)
构建数组中所有标题的列表
<?php
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: Sender Name <sender@domain.com>";
$headers[] = "Bcc: JJ Chong <bcc@domain2.com>";
$headers[] = "Reply-To: Recipient Name <receiver@domain3.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $email, implode("\r\n", $headers));
?>
答案 2 :(得分:0)
有几种方法可以做到。
CREATE PROCEDURE [dbo].[usp_FOBO_InsertMany]
(
@CLIPF [dbo].[CLIPFTable] READONLY,
@CLFPF [dbo].[CLFPFTable] READONLY,
@POLBAPF [dbo].[POLBAPFTable] READONLY,
@POL1PF [dbo].[POL1PFTable] READONLY,
@POL2PF [dbo].[POL2PFTable] READONLY,
@POL3PF [dbo].[POL3PFTable] READONLY,
@POL4PF [dbo].[POL4PFTable] READONLY,
@POL5PF [dbo].[POL5PFTable] READONLY,
@POL6PF [dbo].[POL6PFTable] READONLY,
@POL7PF [dbo].[POL7PFTable] READONLY,
@POLBPF [dbo].[POLBPFTable] READONLY,
@POLGPF [dbo].[POLGPFTable] READONLY,
@POLQPF [dbo].[POLQPFTable] READONLY,
@POLSIPF [dbo].[POLSIPFTable] READONLY
)
AS
EXEC usp_CLIPF_InsertMany @CLIPF
EXEC usp_CLFPF_InsertMany @CLFPF
EXEC usp_POLBAPF_InsertMany @POLBAPF
EXEC usp_POL1PF_InsertMany @POL1PF
EXEC usp_POL2PF_InsertMany @POL2PF
EXEC usp_POL3PF_InsertMany @POL3PF
EXEC usp_POL4PF_InsertMany @POL4PF
EXEC usp_POL5PF_InsertMany @POL5PF
EXEC usp_POL6PF_InsertMany @POL6PF
EXEC usp_POL7PF_InsertMany @POL7PF
EXEC usp_POLBPF_InsertMany @POLBPF
EXEC usp_POLGPF_InsertMany @POLGPF
EXEC usp_POLQPF_InsertMany @POLQPF
EXEC usp_POLSIPF_InsertMany @POLSIPF
GO