php解析变量中的新行

php解析变量中的新行,php,email,line,Php,Email,Line,我的代码从逗号分隔的文件中读取行(电子邮件),并发送电子邮件。它工作得很好,我使用了\r\n \新行,但是当它发送邮件时,用户接收者\r\n \而不是新行 在emailmessages.csv中,它将读取 "from","to","subject","message" "from@example.com","to@example.com","the subject","message is this new line \r\n endline" PHP:代码 $filename = "emai

我的代码从逗号分隔的文件中读取行(电子邮件),并发送电子邮件。它工作得很好,我使用了\r\n \新行,但是当它发送邮件时,用户接收者\r\n \而不是新行

在emailmessages.csv中,它将读取

"from","to","subject","message"
"from@example.com","to@example.com","the subject","message is this new line \r\n endline"
PHP:代码

$filename = "emailmessages.csv";
$csvArray = ImportCSV2Array($filename);

foreach ($csvArray as $row) {
    $to = $row['to'];
    $from = $row['from'];
    $subject = $row['subject'];
    $message = $row['message'];
    $headers  = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1" . "\r\n";
    $headers .= "From: $from" . "\r\n";
    mail($to, $subject, $message, $headers);
}

explode命令是否可以帮助我(explode$message?

大多数情况下以HTML格式呈现的电子邮件,因此请使用

而不是
\r\n

"from@example.com","to@example.com","the subject","message is this new line <br/> endline"
”from@example.com","to@example.com“,”主题“,”消息是这一新行
endline”
我找到了答案

$message = str_replace('\r\n', "\r\n", $message);

您是否收到了一些错误?请发布标题变量如果我收到的整个电子邮件与从csv中输入的内容完全相同,\r\n\n在电子邮件标题中未转换farible已经存在–Jelmergu我几小时前就这样做了,$message=nl2br($message);但用户仍然在电子邮件正文中接收到\n\r\etc,并按分隔符拆分字符串,例如
$array=explode(';','a;b;cd')。为什么要用它?