[英]How to make text bold and italic when I receive email from an html form with php handler
I want to make "new order!" 我想做“新订单”! and "all user input" data in bold when I receive email.
当我收到电子邮件时,“所有用户输入”数据将以粗体显示。 Also want to make "Every customer ... company" italic.
也要使“每个客户...公司”为斜体。
$to = $myemail;
$email_subject = "Order from: $name";
$email_body = "New order!".
"\n Below are the details:\n Name: $name \n Email: $email_address \n Phone Number: $phone_number \n Item Code: $item_code \n Payment Mode: $payment_mode \n Address: $address \n \n Every customer expects quality services from your company";
The PHP mail function has 4 parameters: to, subject, message, and headers. PHP邮件功能具有4个参数:收件人,主题,消息和标题。
mail($to, $subject, $message, $headers);
To enable HTML messages (which would allow you to use tags like <strong>
and <em>
to create bold and italicized texted respectively), simple add the following line into the $headers parameter. 要启用HTML消息(允许您使用
<strong>
和<em>
类的标记分别创建粗体和斜体文本),只需将以下行添加到$ headers参数中即可。
$headers = "Content-Type: text/html; charset=ISO-8859-1\r\n";
Headers can also be used to add formatting to the To and From fields, as well as include CC and BCC: 标头还可以用于将格式添加到“收件人”和“发件人”字段,以及包括CC和BCC:
$headers = "From: From Name<" . strip_tags($from_email) . ">\r\n";
$headers .= "Reply-To: Reply-To Name<". strip_tags($from_email) . ">\r\n";
$headers .= "To: ". strip_tags($to_email) ."\r\n";
$headers .= "CC: susan@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
*Note: This particular example came from here *注意:此特定示例来自此处
*Also Note: The fourth parameter of the mail() function ( $headers ), is completely optional, but in order to enable HTML email (rather than the default plain text email), you must specify it in the $headers parameter. *还请注意:mail()函数的第四个参数( $ headers )是完全可选的,但是要启用HTML电子邮件(而不是默认的纯文本电子邮件),必须在$ headers参数中指定它。
use this code for HTML use in PHP mail 将此代码用于PHP邮件中的HTML
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset: utf8\r\n";
$mail->IsHTML(true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.