Download the PHP package visualbuilder/email-templates without Composer

On this page you can find all versions of the php package visualbuilder/email-templates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package email-templates

Email Template Editor for Filament

Latest Version on Packagist Packagist Downloads run-tests GitHub last commit

Email Preview

Why businesses and applications should use Email Templates

This package provides:-

We use the standard Laravel mail sending capability, the package simply allows content editing and faster adding of new template Classes

Theme Editor

Email Preview

HTML Email Template Editor

Edit email content in the admin and use tokens to inject model or config content.

Email Preview

Version Compatibility

Package Version Filament Laravel PHP
5.x 5.x 11.x, 12.x 8.2+
4.x 4.x 10.x, 11.x 8.2+
3.x 3.x 10.x, 11.x 8.1+

Multitenancy

This package supports Filament's built-in multi-tenancy. When enabled, tenants can customise their own email templates while falling back to global system templates.

Enabling Multitenancy

Via Config

In config/filament-email-templates.php:

Via Plugin (Panel Provider)

Running the Migration

After enabling multitenancy, publish and run the migration to add the tenant column:

The migration adds a nullable tenant foreign key to both the vb_email_templates and vb_email_templates_themes tables.

How It Works

Template Fallback Chain

When retrieving a template (e.g. for sending an email), the package checks:

  1. Tenant-specific template — a template with the matching key AND the current tenant's ID
  2. Global template — a template with the matching key and a NULL tenant ID

This means tenants only need to create templates they want to customise. All other emails automatically use the global system templates.

In Filament Panels

Tenant users see both their own templates and global system templates in the resource list. When a tenant creates a new template, it is automatically assigned to their tenant.

Sending Emails

Pass the tenant ID explicitly when outside a Filament context (e.g. in queue workers or artisan commands):

Within a Filament panel, the tenant is resolved automatically from Filament::getTenant().

Cache Behaviour

Cache keys include the tenant context to prevent cross-tenant cache pollution. When a template is updated or deleted, both the tenant-specific and global cache entries are cleared to ensure the fallback chain stays consistent.

After enabling multitenancy on an existing installation, run php artisan cache:clear to reset stale cache keys.

Installation

Get the package via composer:

Running the install command will copy the template views, migrations, seeders and config file to your app.

The --seed option will populate 7 default templates which you can then edit in the admin panel.

Note: The seeder can also be edited directly if you wish to prepopulate with your own content. database\Seeders\EmailTemplateSeeder.php

Adding the plugin to a panel

Add this plugin to panel using plugins() method in app/Providers/Filament/AdminPanelProvider.php:

Menu Group and sort order can be set in the config

Enabling navigation

In the config file config/filament-email-templates.php navigation can be disabled/enabled

Or you can use a closure to enable navigation only for specific users:

Theme Screenshots

The package supports optional screenshot capture for email template themes. When configured, a "Capture" button appears on the theme list page that generates a preview image of how emails look with that theme's colours. Screenshots are stored via Spatie MediaLibrary on the EmailTemplateTheme model.

Configuring Screenshot Capture

Provide a screenshotCapture closure on the plugin. The closure receives the rendered email HTML string and should return ['image' => binary, 'contentType' => 'image/png'] or null.

When configured, the theme list page will show:

When screenshotCapture is not configured, these features are hidden and the package works exactly as before.

Screenshot Storage

Screenshots are stored as a screenshot media collection (single file) on the EmailTemplateTheme model. A thumb conversion (400x600, contain) is generated automatically for the list view.

The model implements Spatie\MediaLibrary\HasMedia, so you can access screenshots programmatically:

Usage

Tokens

Token format is ##model.attribute##. When calling the email pass any referenced models to replace the tokens automatically.

You can also include config values in the format ##config.file.key## eg ##config.app.name##.

In the email templates config file you must specify keys that are allowed to be replaced.

Insert Token control & token catalogue

Template authors no longer need to remember token names. The content editor has an Insert token toolbar menu listing every available token (grouped by model / Config / General, sorted alphabetically), and typing ## opens an inline autocompleter to search and insert without leaving the keyboard. Inserted tokens render as non-editable badge chips so they can't be mistyped or half-deleted; the badge wrapper is stripped automatically at send time.

The catalogue is powered by the TokenRegistry singleton and built from:

After upgrading, publish the editor plugin asset:

The editor uses a filament-tinyeditor profile named email-template (your default profile plus the token plugin). Define your own email-template profile in filament-tinyeditor config to take full control.

Why still TinyMCE? Filament 5's RichEditor was evaluated for this feature: its native merge tags are flat {{ name }} keys that cannot express dotted ##model.attribute## paths (which would force a migration of all existing template content), badge chips would need a custom TipTap node with a JS build pipeline, and its document sanitizer still normalizes the table-based/inline-styled HTML email markup this package produces. TinyMCE with a native plugin delivers the same UX with zero content migration.

Custom token helpers - IMPORTANT badge-stripping requirement

You can replace the token engine by pointing tokenHelperClass config at your own class. If your helper overrides replaceTokens() without calling the parent, you MUST strip the editor's badge wrapper yourself as the first step - otherwise the <span class="vb-token"> chip markup around inserted tokens leaks into sent emails:

If you simply extend behaviour, prefer calling the parent (which strips badges for you) and post-processing its output:

Implementing out of the box templates

Emails may be sent directly, via a notification or an event listener.

The following email templates are included to get you started and show different methods of sending.

Not all systems will require a login notification, but it's good practice for security so included here.

New User Registered Email

A new Registered event is triggered when creating a new user.

We want to welcome new users with a friendly email so we've included a listener for the Illuminate\Auth\Events\Registered Event which will send the email if enabled in the config:-

User Verify Email

This notification is built in to Laravel so we have overidden the default toMail function to use our custom email template.

For reference this is done in the EmailTemplatesAuthServiceProvider.

Important Register this provider so the override takes effect. Add Visualbuilder\EmailTemplates\EmailTemplatesAuthServiceProvider::class to the providers array in config/app.php (or within your own AppServiceProvider). Without this, Laravel will send its default verification email instead of your customised template.

This can be disabled in the config.

To Enable email verification ensure the User model implements the Laravel MustVerifyEmail contract:-

and include the verified middleware in your routes.

If you have a custom registration page and need to manually generate the verification URL, you can send the notification like this:

Note The notify() call must occur before logging in the user.

User Request Password Reset

Replacing the Filament default email requires extending the Filament RequestPasswordReset class to override the default request method like this:-

And then add this class into the admin panel provider:-

User Password Reset Success Notification

Customising the email template

Some theme colour options have been provided. Email templates will use the default theme unless you specify otherwise on the email template.

In the config file config/filament-email-templates.php logo, contacts, links and admin preferences can be set

If you wish to directly edit the template blade files, see the primary template here:

New templates in this directory will be automatically visible in the email template editor dropdown for selection.

Useful Tip

Not all email clients (e.g., Outlook) render CSS from a stylesheet effectively. To ensure maximum compatibility, it's best to put styles inline. For checking how your email looks across different clients, Litmus Email Previews is highly recommended.

Email blocks

A template can build its body from an ordered list of blocks instead of the single rich text content field. On the template form, switch on Build the body from blocks: the current body is copied into a first Text block, and the Builder replaces the editor. Switching it off stores no layout and the original content is used again. Templates without a layout send exactly as before. Block mode is not offered on templates where is_quote_template is true.

In block mode the email still renders the theme's logo header, hero title, "Need help?" support block and footer around the blocks. A mailable with a public $unsubscribeUrl property (for example a campaign mail) also gets an unsubscribe line under the footer.

Each block renders as one full-width table row with inline styles, an Outlook ghost table at content_width, and explicit background colours, so it holds up in Outlook and Gmail. The package ships these block types:

Name Label Fields
rich_text Text rich text
hero Hero image + alt, heading, text, optional button
two_column Two columns image + alt and rich text per column; columns stack on narrow screens
button Button label, link, alignment (bulletproof button with VML for Outlook)
image Image image, alt text, optional link
divider Divider / spacer small, medium or large spacing, optional line
saved_block Saved block a block from the block library

Links accept an http(s):// URL or a single token such as ##tokenUrl##. Tokens are replaced in text, headings, button labels and links when the email is sent. Builder previews and the template preview use the same renderer as the send, so they match the email (Builder previews show tokens unreplaced).

Block library

The Email Blocks resource stores reusable groups of blocks (a signature, an event banner). Add one to a template with a Saved block item; it renders from the library's current content, so editing the library block updates every template that uses it. A saved block cannot contain another saved block. A deleted or inactive library block is left out of the email (and a warning is logged).

Register a policy for Visualbuilder\EmailTemplates\Models\EmailBlock in your application so only the users you choose can view and edit library blocks.

Block images are uploaded with public visibility to block_images on block_images_disk. Mail clients must be able to fetch them, so use a disk with public URLs:

Upgrading an existing installation: add a nullable JSON layout column to the templates table and create the blocks table (stubs: database/migrations/add_layout_to_email_templates_table.php.stub and create_email_blocks_table.php.stub). If you published the config, copy the new keys above plus navigation.blocks and block_types from the package config.

Adding a block type

Block types are classes implementing Visualbuilder\EmailTemplates\Blocks\Contracts\EmailBlockDefinition, listed by Visualbuilder\EmailTemplates\Blocks\EmailBlockRegistry. Both the form (EmailLayoutBuilder) and the output (EmailLayoutRenderer) read the registry, so a new block type is one class plus one email view. Extending AbstractEmailBlock gives you token replacement (tokenFields()), public image URLs (imageFields()) and rendering through resources/views/vendor/vb-email-templates/email/blocks/{name}.blade.php:

The view receives $block (the block's data after token and image processing) and $theme (the theme colours). Wrap your markup in the shared row partials so it lines up with the other blocks:

Register the class in config (the list is also the order of the "Add block" menu):

or at runtime, e.g. in a service provider's boot():

A class whose name() matches a package block replaces it in the same menu position.

If your _support_block.blade.php override is a fragment without its own <tr><td> wrapper, override email/parts/_support_block_standalone.blade.php to wrap it for block mode.

Translations

Each email template is identified by a key and a language:

This allows the relevant template to be selected based on the users locale - You will need to save the users preferred language to implement this.

Please note laravel default locale is just "en" we prefer to separate British and American English so typically use en_GB and en_US instead but you can set this value as you wish.

Languages that should be shown on the language picker can be set in the config

Language Picker

Flag icons are loaded from CDN: https://cdn.jsdelivr.net/gh/lipis/[email protected]/css/flag-icons.min.css see https://www.npmjs.com/package/flag-icons

Creating new Mail Classes

We've currently opted to keep using a separate Mailable Class for each email type. This means when you create a new template in the admin, it will require a new php Class. The package provides an action to build the class if the file does not exist in app\Mail\VisualBuilder\EmailTemplates.

Build Class Currently generated Mailable Classes will use the BuildGenericEmail Trait

Including other models in the email for token replacement

Just pass through the models you need and assign them in the constructor.

In this example you can then use ##booking.date## or whatever attributes are available in the booking model.

If you need to derive some attribute you can add Accessors to your model.

Both of these function will allow you to use:-

##user.full_name## in the email template:-

OR

Adding Attachments

In here you can see how to pass an attachment:-

The attachment should be passed to the Mail Class and set as a public property.

In this case we've passed an Order model and an Invoice model which has a PDF.

Update From php8.0 the above code can be shortend to:_

The attachment is handled in the build function of the BuildGenericEmail trait. Customise the filename with attachment->filename You should also include the filetype.

Compatible with Laravel 11.x and 12.x mailable methods.

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The GNU GPLv3. Please see License File for more information.


All versions of email-templates with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
filament/filament Version ^5.0
filament/spatie-laravel-media-library-plugin Version ^5.0
spatie/laravel-package-tools Version ^1.16
visualbuilder/filament-tinyeditor Version ^5.0|^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package visualbuilder/email-templates contains the following files

Loading the files please wait ...