Embed logo Markdown emails #51325
Unanswered
adriallongarriu
asked this question in
Q&A
Replies: 2 comments
-
Same problem this is how far it took me, you have to attach file to an email like "logo.png", which then must be referenced inside
where it should simply just live that markup untouched. But yest documentation is not working haven't found the solution yet not a single example <?php
namespace App\Mail;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;
class OrderMail extends Mailable
{
use Queueable, SerializesModels;
public $orderData;
public $orderPDF;
public $logoCID;
public function __construct($orderData = null, $orderPDF = null)
{
$this->orderData = $orderData;
$this->orderPDF = $orderPDF;
}
public function envelope()
{
$subject = $this->orderData['status'] ?? 'Order Mail';
return new Envelope(
from: new Address('info@mail.com', 'From'),
subject: $subject
);
}
public function content()
{
return new Content(
markdown: 'emails.order-mail',
with: [
'message' => $message,
]
);
}
public function attachments()
{
$attachments = [];
// Attach inline logo
$attachments[] = Attachment::fromPath(public_path('img/logo.png'))
->as('logo.png')
->withMime('image/png');
return $attachments;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
this should have fixed it, but no one explain how to use it |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to change the logo for all my emails and embed the logo in to the email.
I pusblish the blades
php artisan vendor:publish --tag=laravel-mail
Edit the file
resources\views\vendor\mail\html\message.blade.php
In the docs https://laravel.com/docs/11.x/mail#inline-attachments it says it should be done this way:
But whit Markdown
$message
is null.I tested with base64 but the image is not showing in gmail:
app\Mail\ContactMail.php
I search and found #47140 tested and the variable
$message
is present inresources\views\emails\contact.blade.php
but not insidemessage.blade.php
How should I make the change or in what way should it be done because by making the change to a single place for all the emails that I have created but also those of Laravel like ResetPassword?
Beta Was this translation helpful? Give feedback.
All reactions