This package allows you to easily send React email emails with Laravel.
composer require maantje/react-email
yarn add @j4mie/react-email
Install React email (automatic, manual).
Create an email in the emails directory e.g. new-user.tsx, make sure the component is the default export.
import { Html } from '@react-email/html';
import { Text } from '@react-email/text';
import * as React from 'react';
export default function Email({ user }) {
return (
<Html>
<Text>Hello, {user.name}</Text>
</Html>
);
}
Set up the email directory in your Laravel .env.
REACT_EMAIL_DIRECTORY="/my/absolute/path/to/react-email-starter/emails/"
Create a Laravel mailable.
php artisan make:mail NewUser
Extend from ReactMailable instead of Mailable.
use App\Models\User;
use Maantje\ReactEmail\ReactMailable;
class NewUser extends ReactMailable
{
public function __construct(public User $user)
{
// public properties will be passed as props to the React email component
// Alternatively use the with property of content
}
public function envelope()
{
return new Envelope(
subject: 'New User',
);
}
public function content()
{
return new Content(
view: 'new-user', // name of the component file without extension
);
}
}
./vendor/bin/pest
If you discover any security related issues, please email author email instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.