'laravel PhpWord send file as email attachment
I am using phpword package in my laravel. I edit content and try to send file as email attachment but email attachment docx file not opens it comes with corrupted file in the attachment. please check below code.
below is my code where i am returning the docx file using phpword
$save_path = $storage_path.'output.docx';
$templateProcessor->saveAs($save_path);
$headers = ['Content-Type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
return $WordContent = response()->download($save_path,null,$headers);
below is code which I use to send email
$message->subject($email_data['title'])
->from($email_data['from_email'], $email_data['from'])
->attachData($WordContent, $email_data['title'].'.'.$extension,'mime'=>$mime]);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
