php - 如何在 Laravel Mailable 中启用 HTML
问题描述
我正在尝试使用可邮寄功能将 HTML 格式的文本发送到 Laravel 中的电子邮件。发送数据时,它包含 HTML 标签。
例子
Order description <p>Lorem Ipsum is simply <b> dummy text</b> of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
代替:
Order description Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
发送邮件.php
public function build()
{
return $this->from('support@example.com')
->to('support@example.com')
->subject('Premium Article Writers')
->view('invoice')
->text('invoice')
->with('data',$this->data);
}
控制器
$data = [
'description' => $request->description,
];
Mail::to($sender)->send(new SendMail($data));
invoice.blade.php
{!! $data['description'] !!}
解决方案
删除->text('invoice')
此以文本格式发送的行。默认情况下它是 HTML。
推荐阅读
- delphi - 是否可以在 Delphi 中以编程方式修改命令行参数?
- spring-kafka - 如何在 Spring Kafka 生产者/消费者中自定义 Json(De)Serializer?(自我回应)
- javascript - JS从对象中的数组中找到匹配的对象
- sql - 在新表中选择相同的帐号
- database - 可以将 Vaadin 中的 JPA 存储库下载为 CSV 文件吗?
- oracle - 从返回对象类型的函数以及提供参数的另一个表中进行选择
- c - MPI 程序错误 - 为什么我总是得到这个退出代码 0xc0000005?
- reactjs - 如何在提供者的值中传递数组和 setArray(React、Typescript、Context)
- java - AWS SDK 无法通过 docker 容器中的区域提供商链找到区域
- php - Opcache 自行清除并中断代码执行