Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theFinalArbiter's avatar

Save attachment file from inbound email from mailgun

Hello Everybody,

I have been following this tutorial

https://laravel-news.com/laravel-inbound-email

and have understood most of it and got it to work. I save the subject and body and what not as I like it to my db.

However I am drawing a blank in successfully saving the attached files on my server (which I will do for now but in the future set up a s3).

I get this working.

$response = (new Client())->get($file['url'], [
    'auth' => ['api', config('services.mailgun.secret')],
]);

but from here how do I save the attachments to lets say "/storage/app/public/files/"

Any help is appreciated!

0 likes
1 reply
theFinalArbiter's avatar
Level 7

This was it!

Storage::put(.$file['name'], $response->getBody());

Please or to participate in this conversation.