A Laravel 5.7 project
I have a form where I need to upload 3 images and 2 pdfs in single form.
What I am going for:
- Submit the form and save data.
- Convert the files uploaded via the user form as a single pdf.
- Sending the converted pdf as a mail attachment using code.
Tried like this
public function sendmail(Request $request){
$data["email"]=$request->get("email");
$data["client_name"]=$request->get("client_name");
$data["subject"]=$request->get("subject");
$pdf = PDF::loadView('mails.mail', $data);
try{
Mail::send('mails.mail', $data, function($message)use($data,$pdf) {
$message->to($data["email"], $data["client_name"])
->subject($data["subject"])
->attachData($pdf->output(), "invoice.pdf");
});
}catch(JWTException $exception){
$this->serverstatuscode = "0";
$this->serverstatusdes = $exception->getMessage();
}
if (Mail::failures()) {
$this->statusdesc = "Error sending mail";
$this->statuscode = "0";
}else{
$this->statusdesc = "Message sent Succesfully";
$this->statuscode = "1";
}
return response()->json(compact('this'));
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire