Php Laravel5.1:如何在不使用视图的情况下传递HTML正文和文本正文?

Php Laravel5.1:如何在不使用视图的情况下传递HTML正文和文本正文?,php,laravel,laravel-5.1,html-email,sendmail,Php,Laravel,Laravel 5.1,Html Email,Sendmail,我尝试在laravel5.1中发送电子邮件,发现Mail:send使用的视图模板如下: Mail::send(['html.view', 'text.view'], $data, $callback); $html_body = $row['Html_Body']; // holds html content $text_body = $row['Text_Body']; // holds text content 问题是我已经准备好发送HTML正文和文本正文来自数据库。如果内容来自以下数据

我尝试在laravel5.1中发送电子邮件,发现Mail:send使用的视图模板如下:

Mail::send(['html.view', 'text.view'], $data, $callback);
$html_body = $row['Html_Body']; // holds html content
$text_body = $row['Text_Body']; // holds text content
问题是我已经准备好发送HTML正文和文本正文来自数据库。如果内容来自以下数据库,如何设置html视图和文本视图:

Mail::send(['html.view', 'text.view'], $data, $callback);
$html_body = $row['Html_Body']; // holds html content
$text_body = $row['Text_Body']; // holds text content
谢谢。

您可以使用:

Mail::send(['text' => $text_body], $data, $callback);

您可以像这样将数据传递到视图

$data = [];
$data['Html_Body'];
$data['Text_Body'];
\Mail::send('html.view', $data , function($message)
{
    $message->to($email)->subject($subject);
});
并将传递给视图的数据用作变量

$Html_Body;
$Text_Body;

这是一种更好的方法,而不是在变量

中使用纯html来附加文本/纯消息,我们可以使用如下addParts方法

$message->to($email_details['to'])
->subject($email_details['subject'])
->from($email_details['from'])
->setBody($email_details['html'], 'text/html');

/* add alternative parts with addPart()*/
$message->addPart($email_details['text'], 'text/plain');

HTML呢?我可以添加Mail::send(['text'=>$text\u body,'html'=>$html\u body],$data,$callback);text是包含将要发送的文本的变量,因此必须连接两个变量,我不想使用任何视图。这就是我在问题中提到的。