laravel - 发送没有主题的 Laravel Mailable
问题描述
我有一个奇怪的问题,我绝对需要从我的 Laravel 应用程序发送一个没有主题的邮件。
目前,这是build()
我的邮件:
public function build()
{
return $this->from('example@example.com')
->view('emails.shipments.remitShipmentFileImages')
->subject(null)
->attach(storage_path($this->file));
}
但我也试过:
public function build()
{
return $this->from('example@example.com')
->view('emails.shipments.remitShipmentFileImages')
->subject('')
->attach(storage_path($this->file));
}
但是当我收到电子邮件测试时,我的主题行中会出现“处理汇款文件”。我究竟做错了什么?
解决方案
如果没有主题集,则最终使用类名:
protected function buildSubject($message)
{
if ($this->subject) {
$message->subject($this->subject);
} else {
$message->subject(Str::title(Str::snake(class_basename($this), ' ')));
}
return $this;
}
您可以尝试覆盖该buildSubject
方法以删除空白主题的后备:
protected function buildSubject($message)
{
$message->subject($this->subject);
return $this;
}
只要 swift 允许空白主题,我想应该没问题。
推荐阅读
- javascript - 为什么在 React-Router-Dom 的路由器中需要“历史”?
- java - NullPointerException:尝试调用虚方法bottomnavigation.BottomNavigationView.setOnNavigationItemSelectedListener
- visual-studio-code - 什么 vs 命令从 URI 路径打开 vscode 中的文件?
- google-sheets - 排序和删除谷歌工作表中的非重复行并保留非重复行和重复行
- postgresql - 如何为 nextauth 引入 heroku postgres 凭证变量
- python - 创建一个 python 包并在安装后像可执行文件一样使用
- go - 以分钟为单位的时区偏移量转换为 24 小时格式的正确方法
- javascript - 为什么这段代码不显示饥饿变量?
- macos - 处理 conan 和 CMake 之间编译器版本的版本不匹配
- web-scraping - 我很难收集内外的值