请帮我在换行符中制作代码消息。我不知道该怎么做,请检查我的代码。希望你能帮助我。提前非常感谢:-
<?php
if(isset($_POST['submit'])){
$to = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8c5d1c5c9c1c4e8cfc5c9c1c486cbc7c5" rel="noreferrer noopener nofollow">[email protected]</a>"; // this is your Email address
$from = $_POST['name']; // this is the sender's Email address
$first_name = $_POST['name'];
$mail=$_POST['email'];
$msg=$_POST['message'];
$phone= $_POST['mob'];
$subject = "contact";
$subject2 = "Copy of your form submission";
$message = "Name:-". $first_name . "Email:-". $mail . "Phone Number:-
".$phone. " Message:-".$msg." " ;
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
?>
我想收到这样的消息:-
Name:-loreal
email:- Mymail
phone Number:- 987654321
Message:- Hi
最佳答案
尝试在消息中使用 \n
:
$message = " Name:-". $first_name . "\n Email:-". $mail . "\n Phone Number:-
".$phone. "\n Message:-".$msg." " ;
它们是转义序列。 \n
是换行符,\r
是回车符。 \r
是回车符 \n
是换行符(或新行)
- Mac:
\r
- Linux/Unix:
\n
- Windows:
\r\n
关于php - 如何在PHP中使用换行符发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50771809/