Noo*_*Dev 1 php laravel laravel-5
我有一个以 base64 编码的 PDF,它是我数据库中的一个属性,我通过 Laravel 发送电子邮件,但我不知道如何将 base64 作为 PDF 发送。
public function toMail()
{
$pdf_decoded = base64_decode($this->table->raw_label);
$message = (new MailMessage)
->subject(env('APP_NAME').' - HI #'. $this->order->id)
->greeting('¡Hi!');
if(env('APP_URL') == 'http://test.test'){
$message->bcc(['test@test.com']);
}
return $message;
}Run Code Online (Sandbox Code Playgroud)
我知道附加属性,但我不知道如何实现它。
小智 6
你实际上可以通过MailorNotification类来做到这一点,我个人会使用 aNotification但这取决于你。只需使用该->attach($pathToFile)方法并将文件路径作为参数提供给它。
这是一个使用 a 的示例Notification,希望对您有所帮助!
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('Please download the PDF.')
->attach(public_path($this->filename), [
'as' => 'filename.pdf',
'mime' => 'text/pdf',
]);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2613 次 |
| 最近记录: |