与Phpmailer的换行问题

时间:2014-05-16 18:41:54

标签: phpmailer

每个人都说使用\ n作为明文的分界线;我怎么试过一切都不会工作,有人可以帮我一把。带引号,不带引号。请告诉我正确的方法。这是我的代码:

include("class.phpmailer.php");   
require 'PHPMailerAutoload.php';

$mail = new PHPMailer();
$mail->isSendmail();
$mail->setFrom('info@test.org', 'test');
$mail->addAddress('test@hotmail.com');
$mail->Subject = $title;   
$mail->Body = ''.$descrip.' "\n" Vid Upl by '.$name.'';
$mail->AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']);
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
    echo "Msg sent!";
    } 

1 个答案:

答案 0 :(得分:1)

$mail->Body = ''.$descrip.' "\n" Vid Upl by '.$name.'';

应该是

$mail->Body = $descrip . "\nVid Upl by " . $name;

或简称

$mail->Body = "$descrip\nVid Upl by $name";