How to attach file to Laravel 5.2 mail from Base64 format

后端 未结 1 606
清歌不尽
清歌不尽 2021-01-16 08:10

I have angular app as frontend and laravel 5.2 as api backend. My angular app send parameter to my laravel controller this:

{
     name: \"My Name\", 
     e         


        
相关标签:
1条回答
  • 2021-01-16 08:31

    Ok i solved my problem and it's easy ...

    Just changed attach to attachData

    $data = [
        'name' => $request->input('name'),
        'email' => $request->input('email'),
        'subject' => $request->input('subject'),
        'message' => $request->input('message'),
        'attachment' => $vAttachment,
        'store' => $vStore->name,
    ];
    
    Mail::send('emails.call-us', ['data' => $data],
        function ($m) use ($data) {
            $m->from($data['email'], $data['name'] . ' - ' . $data['store']);
            $m->attachData(base64_decode($data['attachment']['base64']), $data['attachment']['filename'], ['mime' => $data['attachment']['filetype']]);
            $m->to(env('EMAIL_CONTACT_US'));
            $m->subject($data['subject']);
    

    Silly me :)

    0 讨论(0)
提交回复
热议问题