How to send an attachment from request to mail without first saving it to storage?


How to send an attachment from request to mail without first saving it to storage?

public function build(){
    $email = $this->from('mymail@gmail.com')
                        ->view('emails.contact');
     foreach(request()->file() as $file) {
                $email->attach($file->getRealPath(), [
                'as' => $file->getClientOriginalName(),
                'mime' => $file->getMimeType(),
        ]);
    }
}
return $email;

You can see it in the documentation https://laravel.com/docs/9.x/mail#attachments


Comments

Popular posts from this blog

Why Mark Zuckerberg’s Choose 4

Error message when I run sudo: unable to resolve host (none)

Convert MBR to GPT