Laravel 5.5,带附件的排队邮件

时间:2018-01-28 18:22:32

标签: laravel queue email-attachments

我想发送包含附件的排队邮件。当我没有排队测试它工作正常 但是当我将邮件放入队列时,邮件中不包含附件。 我在作业

中看到序列化字符串中的文件路径

我收到错误非法字符串偏移'文件'。

关于什么错误的任何线索?

$attachments = [
    storage_path( 'app/pdf.pdf' ),
    storage_path( 'app/pdf-2.pdf' ),
];
dispatch( new ProcessReports( $this->report, $attachments ) )->delay( now()->addMinutes( 1 ) );

我使用mailable设置邮件:

$mailable = $this->subject( 'Your reports' )
                 ->view( 'email' );

if ( count( $this->attachments ) > 0 ) {
    foreach ( $this->attachments as $attachment ) {
        $mailable->attach( $attachment );
    }


}

return $mailable;

最后是作业处理程序:

public function __construct( Report $report, $attachments = array() ) {
    $this->report      = $report;
    $this->attachments = $attachments;
}

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle() {

        $email = new ReportSent( $this->report, $this->attachments );
        Mail::to( $this->report->user->email )
            ->send( $email );
    }

0 个答案:

没有答案