简体   繁体   English

发送附件中的pdf(Laravel Mail)

[英]Send pdf in attachment (Laravel Mail)

I have this code to get some HTML stored in the column "content" of the "badges" table in a pdf: 我有这个代码来获取一些HTML存储在pdf中“徽章”表的“内容”列中:

 $pdf = app()->make('dompdf.wrapper');
 $pdf->loadHTML($badgeContent->badge->content);

Do you know if is possible to send this pdf in a attachment using Laravel Mail? 您知道是否可以使用Laravel Mail将此pdf发送到附件中?

You could sent almost any file in attachment 你几乎可以发送附件中的任何文件

in laravel, create a new mailable inside build paste this code 在laravel中,创建一个新的mailable内部构建粘贴此代码

public function build()
{
    return $this->view('emails.orders.shipped')
                ->attach('/path/to/file');
}

If you need more information on this check laravel's documentation (this code is copied from the laravel's documentation https://laravel.com/docs/5.6/mail#writing-mailables 如果您需要有关此检查laravel文档的更多信息(此代码是从laravel的文档中复制的https://laravel.com/docs/5.6/mail#writing-mailables

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM