1. Go to this page and download the library: Download evanschleret/lara-mjml library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
evanschleret / lara-mjml example snippets
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class WelcomeMail extends Mailable
{
use Queueable;
use SerializesModels;
public function __construct(
public string $userName,
) {}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Welcome',
);
}
public function content(): Content
{
return new Content(
view: 'emails.welcome',
with: [
'userName' => $this->userName,
],
);
}
}
use App\Mail\WelcomeMail;
use Illuminate\Support\Facades\Mail;
Mail::to($user->email)->send(new WelcomeMail($user->name));
namespace App\Notifications;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class WelcomeNotification extends Notification
{
use Queueable;
public function __construct(
private readonly User $user,
) {}
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage())
->subject('Welcome')
->view('emails.welcome', [
'userName' => $this->user->name,
]);
}
}