How to display image sent from Laravel in email message

majkan93

I'm trying to display image (uploaded in my web app) transported from LARAVEL in the email message.

Picture of received email:

email

Currently, I achieved to show the image as an attachment of an email message, but my goal is to display the image as a cover photo of an email. The content of the email message is developed within the catalogEmail.blade.php file.

CatalogController.pho

function Sendcatalog (Request $request, $url){

 $this->validate($request, [
      'email'  =>  'required|email'

     ]);

         $language=Language::where('url', '=', $url)->first();
              if(count($language)==0){
                abort(404);
               }      
         $emailStorage= new EmailStorage;
         $emailStorage -> email = $request -> input('email');   
         $emailStorage->save();
         $catalog=Catalog::first();



           $data = array(
            'email'   =>   $request->email,
            'filename'   =>    $catalog->file_name,
            'title'   =>    $catalog->title,
            'content'   =>    $catalog->content,
            'post_thumbnail'   =>    $catalog->post_thumbnail,
            'post_thumbnail2'   =>    $catalog->post_thumbnail2,
        );




     $visitorEmail=$request->email;   
     Mail::to('[email protected]')->send(new SendCatalogInfo($data));
     Mail::to($visitorEmail)->send(new SendCatalog($data));



 return back()->with('successPost', 'You will get soon catalog on your email address');

}

Web.php

Route::post('/sendcatalog/{url}', 'CatalogController@Sendcatalog')->name('catalog.send');

SendCatalog.php (mail.php)

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendCatalog extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($data)
    {
         $this->data = $data;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {

             return $this->from('[email protected]')->subject('KAJO company')->attach(public_path('uploads/catalogs/pictures/'. $this->data['post_thumbnail2']))->view('email/catalogEmail')->with('data', $this->data);
    }
}

CatalogEmail.blade.php

<h3>Hello, catalog {{ $data['title'] }}</h3>


<p>Hello, catalog {!! $data['contnet'] !!}</p>


          <img src="{{public_path('uploads/catalogs/pictures/'.$data['post_thumbnail2'])}}"/>  
Preuzmite katalog iz linka

<a href="{{asset('storage/upload/'.$data['filename'])}}" class="btn btn-hot text-capitalize btn-xs" download>Preuzmi fajl</a> 
Rouhollah Mazarei

You must prepend the tdl to the image source address. Something like this:

<img src="http://example.com/{{public_path('uploads/catalogs/pictures/'.$data['post_thumbnail2'])}}"/>  

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Laravel get email sent success message

DocuSignApi - how to set the email message sent

How to display an image at HTML email

How to display image in laravel after return image from guzzle API

How to display a success message upon redirection from controller in Laravel?

How to display array data after store & email sent?

laravel how to display flash message with confirm message

How to connect a draft to the message that is sent from it

How to add reaction to message sent from bot

How can Place an image in my EMail message

How to change default Laravel 8 Fortify sent email when email request is sent?

django: how to display image in html_email

How to display the image from the public/storage/images in Laravel

How i can display image from path Laravel?

how to display image from path stored in database? in laravel

Laravel Nova: how to display image from binary string?

How to display an image from s3 bucket in laravel 9

Getting only last sent message from forwarded email message using regex in php

How to Get Message_id from sent message By BOT Telegram?

Apache James server: how to recognise whether a email in the inbox table is a reply of a previous sent email or a new message sent by the user?

How to display a message from anacrontab

How Email Sent In Django

Laravel 5.7 - Verification email is not sent

Can I display a message from return ->with() in laravel?

How display image in laravel 5.3

How to fix login page Laravel ui auth didn't display any error message when wrong input email/password

How would I get the current time every minute when an email is sent and display that time in the body of the email?

How to add email addresses from a message to a textbox?

How to display an image as a message in an Alert Dialog box?