簡體   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