email send using queue with attachment laravel code example

Example 1: email send using queue with attachment laravel

<?php

namespacde App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendMailWithAttachment extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    /**
    * Create a new message instance.
    *
    * @return void
    */
    public function __construct()
    {
        //
    }

    /**
    * Build the message.
    *
    * @return $this
    */
    public function build()
    {
          return $this->to('[email protected]')
              ->attach(storage_path('app/1569316022.jpg'))
              ->markdown('mail_example');
    }
}

Example 2: email send using queue with attachment laravel

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

d{
    use Queueable, SerializesModels;

    /**
    * Create a new message instance.
    *
    * @return void
    */
    public function __construct()
    {
        //
    }

    /**
    * Build the message.
    *
    * @return $this
    */
    public function build()
    {
          return $this->to('[email protected]')
              ->attach(storage_path('app/1569316022.jpg'))
              ->markdown('mail_example');
    }
}

Tags:

Misc Example