I want to send an email attaching the logo in the email body. I am using Laravel. But whenever I am trying to attach an image, it is not showing in the body. Instead, it is sending as an attachment. Any suggestion or article link would be helpful for me
Sample
Mailable
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class SubscribeMail extends Mailable
{
use Queueable, SerializesModels;
public $data;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject('Test Mail')->view('mails.subscribe');
}
}
Template Body
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<img src="{{$message->embed('https://itecounsel.com/public/assets/images/logo.png')}}" style="max-width: 100px"/>
{{$data['email']}} has subscribed
</body>
</html>
After doing several research I found the solution. Wrapping the image into a table works for me
Code
<div class="wrapper">
<div class="container">
<header class="header">
<h2 class="header-text">ITEC - International Training and Education Counsel</h2>
</header>
<section class="body">
<table class="info-table" cell-padding="5">
<thead>
<tr>
<th colspan="2">
<a href="https://www.google.com/url?sa=i&url=https%3A%2F%2Fen.m.wikipedia.org%2Fwiki%2FFile%3AOikya_Front_Logo.png&psig=AOvVaw1gZAn58ULm8UEoqIhPaGNC&ust=1622533229901000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDEirm18_ACFQAAAAAdAAAAABAP">
<img src="https://itecounsel.com/public/assets/images/logo.png" alt="Image" style="width: 100px;">
</a>
</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong class="point">Student Name: </strong></td>
<td></td>
</tr>
<tr>
<td><strong class="point">Contact: </strong></td>
<td></td>
</tr>
<tr>
<td><strong class="point">Email: </strong></td>
<td></td>
</tr>
<tr>
<td><strong class="point">Nationality: </strong></td>
<td></td>
</tr>
<tr>
<td><strong class="point">Qualification: </strong></td>
<td></td>
</tr>
<tr>
<td><strong class="point">Relevant Work Exprience: </strong></td>
<td></td>
</tr>
<tr>
<td><strong class="point">Work Location: </strong></td>
<td></td>
</tr>
<tr>
<td><strong class="point">Designation: </strong></td>
<td></td>
</tr>
</tbody>
</table>
</section>
</div>
</div>