当我从php发送邮件和ckeditor textarea中的类型邮件时,我收到如下邮件:
我想删除\ n \ n
提前致谢。
这是我的代码
<?php
$to = $resrow['recevie_email'];
$subject = $esub;
$message = "Hi Admin,<br>";
$message .= "<br/><br/>";
$message .= "There is a query from user described below.<br>";
$message .= "Name : ".$_SESSION['first_name'] ." ".$_SESSION['last_name'];
$message .= "<br/>";
$message .= "ROLE : ".$mail_from;
$message .= "<br/>";
$message .= "Email : ".$_SESSION['EMAIL'];
$message .= "<br/>";
$message .= "Phone : ".$userdetail['phone'];
$message .= "<br/>";
$message .= "Query : ".$data;
$message .= "<br><br>";
$message .= "Please contact ".$mail_from." on above details to resolve the query.";
$message .= "<br><br>";
$message .= "Thank you,<br>";
$message .= "Elevon Team.";
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: Elevon <'.$resrow['send_email'].'>';
$message = trim($message, "\n");
$mail_conf = mail($to, $subject, $message, implode("\r\n", $headers));
?>
答案 0 :(得分:0)
好的,我在这里找到了答案,要从邮件正文中删除\ n \ n,我们必须使用str_replace,如下所示
$ data = str_replace(&#39; \ n&#39;,&#39;&#39;,$ data);
这里是完整的代码
<?php
$data = str_replace('\n',' ',$data);
$to = $resrow['recevie_email'];
$subject = $esub;
$message = "Hi Admin,<br>";
$message .= "<br/><br/>";
$message .= "There is a query from user described below.<br>";
$message .= "Name : ".$_SESSION['first_name'] ." ".$_SESSION['last_name'];
$message .= "<br/>";
$message .= "ROLE : ".$mail_from;
$message .= "<br/>";
$message .= "Email : ".$_SESSION['EMAIL'];
$message .= "<br/>";
$message .= "Phone : ".$userdetail['phone'];
$message .= "<br/>";
$message .= "Query : ".$data;
$message .= "<br><br>";
$message .= "Please contact ".$mail_from." on above details to resolve the query.";
$message .= "<br><br>";
$message .= "Thank you,<br>";
$message .= "Elevon Team.";
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: Elevon <'.$resrow['send_email'].'>';
$message = trim($message, "\n");
$mail_conf = mail($to, $subject, $message, implode("\r\n", $headers));
?>