繁体   English   中英

如何格式化php电子邮件

[英]how to format php email

我会让它变得非常简单。 我想通过php发送电子邮件。 现在这里是代码。

$line = '\n';
$a = "Customer Phone: ";
$b = "Customer Last Name: ";
$message = $a.$number.$line.$b.$LastName;       

$to = "forgotten_tarek@yahoo.com";
$subject = "Umrah Booking";
$from = $mailer;
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);

这是输出:

Customer Phone: 0712345678\nCustomer Last Name: Showkot

并且电子邮件显示没有发件人。 nobody说。

我希望电子邮件看起来像:

Customer Phone: 0712345678
Customer Last Name: Showkot

我还想表明该电子邮件来自example@example.com

1)将'\\n'更改为"\\n" 特殊字符(例如\\n )仅在双引号字符串中解释。

2)尝试将"From:"更改为"From: " 或者,变量$from也许没有价值。

你也可以使用html邮件,因为你可以发送一个实际使用html格式化的邮件..这很简单,yu几乎可以使用yu用于格式化html内容的所有标签,甚至可以添加css。 。! 你需要添加标题来发送HTML邮件。

这是一个例子..!

$to = "sended@test.com";
$subject = "Test mail";
$a = "Customer Phone: ";
$b = "Customer Last Name: ";
$message = $a.$number.$line.$b.$LastName;  
$message="
<html>
<body>
  <h1>$a</h1>: $number <br> <h1>$b</h1>: $LastName<br>
</body>
</html>";

$from = "tester@test.com";
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";

mail($to,$subject,$message,$headers);

试试这个。,它会工作..! :)

$line = "\n";
$a = "Customer Phone: ";
$b = "Customer Last Name: ";
$message = $a.$number.$line.$b.$LastName;

$to = "forgotten_tarek@yahoo.com";
$subject = "Umrah Booking";
$from = $mailer;
$headers = "From: " . $from. "\r\n".
'Reply-To: '. $from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to,$subject,$message,$headers);

您可以在消息标记中输入html,例如:

$message = '<html><body>';
$message .= '<h1>Hello, World!</h1>';
$message .= '</body></html>';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM