我正在尝试使用php smtp 身份验证发送格式化的电子邮件,但由于某种原因\n
,\r\n
并且PHP_EOL
无法格式化消息,因此所有内容都出现在一行上。
以下是我尝试过的
$order .= "Title : {$title}" . PHP_EOL
."Author : {$author}" . PHP_EOL
."ISBN : {$isbn}" . PHP_EOL
."Publisher : {$publisher}" . PHP_EOL
."Supplier : {$supplier}\n
Quantity : {$qty}\r\n
该变量$order
包含电子邮件的正文。这是我的sendMail()
功能的一部分
$from = "{$sender_name} <{$sender}>";
$to = $reciever." <$email>";
$subject = $subj;
$body = $msg;
$host = "mail.thekingsbooks.com";
$username = "noreply@thekingsbooks.com";
$password = "password";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory(
'smtp',
array(
'host' => $host,
'auth' => true,
username => $username,
password => $password
)
);
$mail = $smtp->send($to, $headers, $body);
发送的邮件是这样的
Ordered items\r\nTitle : A Retreat With Pope John Paul II: Be Not Afraid (Retreat With-- Series)\r\nAuthor : \r\nISBN : 0867164204\r\nPublisher : \r\nSupplier : \r\n\r\n Quantity : 6\r\n\r\n
关于如何格式化电子邮件正文的任何建议?谢谢