Skip to content

Attachments are not being sent #9

@CleytonBonamigo

Description

@CleytonBonamigo

Hello.

I'm trying to send attachments with e-mail, but are not being sended.
The email never comes, it's just to test.
If attachments are not send, the email arrives

Here is my code in App\Mail\OrderShipped.

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use function GuzzleHttp\Psr7\mimetype_from_filename;

class OrderShipped extends Mailable
{
    use Queueable, SerializesModels;

    protected $config;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($config)
    {
        $this->config = $config;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $attachments = json_decode($this->config['attachments']);
        return $this->view('welcome')
            ->attach($attachments[0]->path, [
                'as' => $attachments[0]->name,
                'mime' => mimetype_from_filename($attachments[0]->path)
            ]);
    }
}

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions