我正在使用 PHPMailer 发送邮件,我有 textarea 作为邮件正文。所以当我写文本时我需要换行但是当我换行时它不起作用,当文本丰富到邮件时,它仍然只显示一个线。我的PHP代码如下:
<?php
if(isset($_POST['submit'])){
require_once('class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = str_replace ('<br>' , '\r\n', $_POST['about']); // $_POST['about'] is the value text take from the body text area of mail
//$body = $_POST['about'];
$from = $_POST['from'];
$mail->AddReplyTo($from,$from);
$mail->SetFrom($from, $from);
$mail->AddReplyTo($from,$from);
$address = $_POST['email'];
$mail->AddAddress($address, $address);
$mail->Subject = $_POST['subject'];
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message envoyé!";
}
}
?>
请哪位帮我解决这个问题,谢谢。