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",
email: "example@email.com",
subject: "Hello",
message: "This My Message",
attachment: {
base64: /9j/4AAQSkZJRgABAQEASABIAAD/2wCEAAMCAgMC.....
filetype: "application/rar",
filename: "example.rar",
filesize: 198141,…
}
}
And in my laravel controller i have code like this
$data = [
'name' => $request->input('name'),
'email' => $request->input('email'),
'subject' => $request->input('subject'),
'message' => $request->input('message'),
'attachment' => $request->file('attachment'),
'store' => 'Store Name',
];
Mail::send('emails.call-us', ['data' => $data],
function ($m) use ($data) {
$m->from($data['email'], $data['name'] . ' - ' . $data['store']);
$m->attach($data['attachment'], [as => 'example.rar', ['mime' => 'application/rar']);
$m->to(env('EMAIL_CONTACT_US'));
$m->subject($data['subject']);
});
What is the recommended way of send file as attachment email from base64 format? Thanks
Ok i solved my problem and it's easy ...
Just changed attach to attachData
Silly me :)