Angnima Sherpa
Angnima Sherpa

Reputation: 234

sending mail with attachments in laravel 5.4 through mailgun

I'm having problems sending attachments in mail with mailgun.

When I go to logs in mailgun, the mail sent shows :

      "attachments": [],

Here's my code :

      $location = Storage::get('attachments/'.$this-attachments->file_name);
      return $this->markdown('emails.create',["desc" => $this->mail->description])
           ->subject($this->mail->subject)
           ->attach($location);

I got raw encoded codes when I return the $location so i tried doing with public_path() but the result was same( "attachments":[], <- in mailgun logs ).

Am i doing it wrong? How do i get the attachment in the mail? The mail is going through but not with attachments.

Thanks for your time.

Upvotes: 0

Views: 1369

Answers (2)

Vpa
Vpa

Reputation: 737

You wrote

$location = Storage::get('attachments/' . $this-attachments->file_name);

But it should be

$location = Storage::get('attachments/' . $this->attachments->file_name);

You forgot the > in $this->

Upvotes: 1

AddWeb Solution Pvt Ltd
AddWeb Solution Pvt Ltd

Reputation: 21681

Try below code with storage_path():

$location = storage_path('attachments/'.$this-attachments->file_name);

return $this->markdown('emails.create',["desc" => $this->mail->description])
->subject($this->mail->subject)
->attach($location);

Upvotes: 1

Related Questions