I want to send email with product images.So i am using laravel
markdown mail template.But the probelm is when i send mail i only get
the image link which is given bellow
http://127.0.0.1:8000/storage/images/vAO6oZDeIIFYwtz95dlz5ZyqghrOTsL0GNkDycJq.png
here is my markdown template code:
<head> <style> p{ font-family:verdana; font-size: 10px; margin : 0; } .btn{ text-align:center; } .loginButton { padding: 7px 15px 8px 20px; } </style> </head> @component('mail::message') <p>Dear {{ $data['supplier']->name}},</p><br> <p>There is a new business opportunity:</p> <p><b>Industry:</b> {{ $data['rfq']->category->industry }}</p> <p><b>Product Category:</b> {{ $data['rfq']->category->name }}</p> <p><b>Title:</b> {{ $data['rfq']->title }}</p> <p><b>Quantity:</b> {{ $data['rfq']->quantity }}</p> <p><b>Unit:</b> {{ $data['rfq']->unit }}</p> <p><b>Unit price:</b> {{ $data['rfq']->unit_price }}</p> <p><b>Payment method:</b> {{ $data['rfq']->payment_method }}</p> <p><b>Delivery time:</b> {{ $data['rfq']->delivery_time }}</p><br> <p>To reply, please login to your MerchantBay account and find the request in your RFQ menu.</p><br> <p>You are receiving this notification because you produce Full Body in the requested country and the requested order quantity matches the information provided in your company profile. If you think this request does not fit to your business, please update your company profile.</p><br> <p>Best regards,</p> <p>your Merchant Bay team</p> @foreach($data['rfq']->images as $image) {{ asset('storage/'.$image->image) }}<br> {{-- <img src="{{ asset('storage/'.$image->image) }}" class="img-responsive"> --}} @endforeach @endcomponent
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You have to embed the image to the email template
This is an example, you can try like this
<img src="{{ embed(public_path() . '/logo.png') }}" alt="" class="top-logo" style="display: block; margin-left: auto; margin-right: auto;">
Method 2
Try using the helpers paths instead.
If your images are being saved in the public folder use
public_path('folder_name/filename.png')
or if they are saved in the storage folder use
storage_path('folder_name/filename.png').
I assume you are using the public folder because you are using asset() so you should try
<img src="{{ public_path('storage/'.$image->image) }}" class="img-responsive">
Laravel Doc https://laravel.com/docs/8.x/helpers#method-storage-path
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0