How to attach image from storage in mail Laravel

laravel smtp

2012 观看


161 作者的声誉

I am trying to attach an image stored in [storage/app/proof] onto an email however, I am getting...


instead of the image file and this is what I've done so far.


        $user->accType = "TBC";
        //stored as "proof/img_name.jpg" in DB
        $user->proofLink = request()->file('proofFile')->store('proof'); 
        \Mail::to('')->send(new ConfirmAccount($user));

ConfirmAccount.php enter image description here

What am I doing wrong?

作者: SpencerChantler123 的来源 发布者: 2017 年 12 月 27 日

回应 (2)


7599 作者的声誉

Hi you are missing the attachment mime type..

                attach('/path/to/file', [
                    'as' => 'name.pdf',
                    'mime' => 'application/pdf',

you can find more on

Hope this helps.

作者: Adnan Mumtaz 发布者: 27.12.2017 05:01


161 作者的声誉

The error was actually caused by an incomplete path.

$location = storage_path("app/$user->proofLink");

was returning "app/" instead of "app/records/img_name.jpg".

To solve this, I edited ConfirmAccount.php as follows:

 public function __construct(User $user)
    $this->URL = $user->proofLink;
  public function build()
    $location = storage_path("app/$this->URL");
    return $this->view('emails.confirmaccount')->attach($location);
作者: SpencerChantler123 发布者: 27.12.2017 05:24