Hi @gabotronix,
Change your maildriver to Mailgun, it is already installed in Laravel (see config/mail.php) Now you can use the default mail functionlity from Laravel
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everybody, I'm using Mailgun's php SDK to send mails, after looking through the docs you can apparently send html/text mails but what about laravel's blade templates, my templates have some variables like order details and user info that I want my templates to have, is it possible to do?
So my questions are:
How can I share variables with my blade templates and send them through Mailgun's API.
How can I reference my my blade templates when filling the parameters of my mailgun API call.
I 'd rather not download any composer package like Bogardo since they are outdated.
This is what I have so far:
public static function sendMailGun($order)
{
$mailData = [
'subject' => 'Tus códigos de descuento para '.config('app.name').'.',
'destination' => $order['purchaser']['email'],
'order' => $order
];
$mg = Mailgun::create('YOUR_API_KEY');
//how can I pass $mailData into my views?
$mg->messages()->send('YOUR_DOMAIN_NAME', [
'from' => 'Excited User <mailgun@YOUR_DOMAIN_NAME>',
'to' => 'Baz <YOU@YOUR_DOMAIN_NAME>',
'subject' => $mailData['subject'],
'html' => 'I WANT TO REFERENCE emails.discount-mail.blade.php HERE'
]);
}
Please or to participate in this conversation.