Laravel-Mail: how to get through & # 8594; attachData to view

I am trying to use a built-in application in laravel mail, but it seems unsuccessful. I also tried this one , but it doesn’t work, inserting raw data. I have a base 64 image / png here an example of this.

Now I'm trying to use attachData, but how to transfer ->attachDatato mine mailtransaction.blade. I supposedly get attachData from my controller, but which variable should I name?

controller.php

Mail::send(['html'=>'mailtransaction'], $data_content, function($msg) use ($to, $issueType, $base64){
        $msg->to($to); // change this upon finishing
        $msg->attachData($base64, 'test.png', ['mime'=>'image/png']);
        $msg->subject($issueType);
      });

mailtransaction.blade

<!DOCTYPE html>
<html>
<head>
</head>
<body style="width:100%;">
    <div style="border:0px solid #000; width:1000px !important;">
        <div style="display: inline-block;">
            <img src="{{$message->embed('storage/app/public/images/logo.png')}}" height="50px" width="50px">
        </div>
        <div style="display: inline-block; vertical-align: top;">
            <div style="font-size:24px; margin-bottom: -10px;">Fraud Detection Tool</div>
            <div>Suspicious Transaction details</div>
        </div>
        <hr style="border:0px; border-bottom:1px solid #000; width:1000px;">
        <div class="container">
            {{$msg}}
            //I supposedly get the attachData from my controller but what variable should I call?
        </div>
        <hr style="width:1000px;">
        <div class="container_mail" style="width:600px !important;">
            <img src="{{}}" height="auto" style="max-width: 1000px">
        </div> 
    </div>
</body>
</html>
+4
source share
2 answers

second send(), array . -

Mail::send('mailtransaction', ['data_content'=>$data_content,'base64'=>$base64], function($msg) use ($to, $issueType){
    $msg->to($to); // change this upon finishing
    $msg->attachData($request->getBase64, 'test.png', ['mime'=>'image/png']);
    $msg->subject($issueType);
  });

, , data_content base64 as -

{{$data_content}}
{{$base64}}
+1

attachData . $data_content :

$data_content['attachedImage'] = ...; // Get the regular data of the image, not the base64 version

embedData:

<img src="{{ $message->embedData($attachedImage, 'test.png') }}" align="right" width="150px" height="100px"/>

base64, $data_content base64 :

<img src="data:image/png;base64,{{ $attachedImage }}" align="right" width="100px" height="100px"/>
+1

Source: https://habr.com/ru/post/1692864/


All Articles