'Laravel queue email with attachment

Hi everyone i'm just trying to queue my email with attachment in laravel project, but it does not seems to work. when i try to send an attachment without queue my mail it is working absolutely fine, but when i put my email in queue it just stop working. email is sent but attachment doesn't.

here is my code for email in controller

 Mail::to($request->email)->send(new ContactUsEmail($contact_us));

and below code is from my mail job

class ContactUsEmail extends Mailable implements ShouldQueue
{



 use Queueable, SerializesModels;
/**
 * Create a new message instance.
 *
 * @return void
 */
protected $data;
public function __construct($data)
{
    $this->data = $data;
}

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    $extension = explode('.',$this->data->attachment)[1];
    return $this->subject($this->data->topic)->attach(public_path('/storage/attachments/contact-us/' . $this->data->attachment),
        [
            'as' => $this->data->attachment,
            'mime' => 'application/'. $extension
        ])->markdown('mail.contact-us' ,[
        'subject' => $this->data->subject,
        'name' => $this->data->name,
        'email' => $this->data->email,
        'description' => $this->data->description,

    ]);
}


}

please let me know if i'm doing something wrong or missing something. i appreciate your response



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source