Download the PHP package statikbe/laravel-mail-template-engine without Composer

On this page you can find all versions of the php package statikbe/laravel-mail-template-engine. 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 laravel-mail-template-engine

Laravel Mail Template Engine

The Laravel Mail Template Engine makes it possible to create mail templates for your transactional mails. These mail templates can hold content and recipient variables which can be filled when triggering the mail.

This package works together with our Laravel Nova Mail Editor that provides a UI to let content managers edit translations.

How it works

The packages combines 3 different sets of data to send a transactional mail.

  1. Firstly there is the Mail class: here you define a name, content variables and recipient variables.
  2. Next up you store your mail templates in your database, you can do this in Nova using Laravel Nova Mail Editor. Or you write your own interface to save the templates.
  3. Finally, you call the mail class and fill in its variables (content and recipient). At this moment the engine will look for all templates using this class, starts filling them with the provided variables and send them to the selected recipients.

Installation

  1. Install using composer:

  2. Publish the mail template migration and config

  3. Run the mail template migration

How to use

The mail class

This class will decide what content variables are available in your mail template and will be used to decide when a mail is send.

You can generate a mail with the following command

After creating a Mail class, add them to the config mail-template-engine.php mails.

An example of a Mail class can be found at src/Mails/ResetPassword.php.

The Mail Templates

Mail templates are stored in the database. This uses the model Statikbe\LaravelMailEditor\MailTemplate and can be created like any other model. A mail template can be localized, we use Spatie's translatable package for this to work. More information can be found on their page: Laravel Translatable.

You can use the keys from your corresponding mail_class to place variable data inside the mail template.

The MailTemplate model consists off:

Name Type Description Example
mail_class string A mail class from config mail-template-engine.mails verify-email
name string Just a descriptive naming of the mail for an index page Email verification mail
subject json (translatable) The subject, fillable with ContentVariables from the corresponding Mail Class {"en": "Welcome [[name]], please verify your email"}
body json (translatable) The body, fillable with ContentVariables from the corresponding Mail Class {"en": "Welcome [[name]], please verify your email using the following url [[url]]."}
sender_name json (translatable) The sender by name {"en": "Statik"}
sender_email json (translatable) The sender by email {"en": "[email protected]"}
recipients json The recipients of the mail, an array filled with both RecipientVariables from the Mail Class and/or plain emails ["user","[email protected]"]
cc json The cc of the mail, an array filled with both RecipientVariables from the Mail Class and/or plain emails ["user","[email protected]"]
bcc json The bcc of the mail, an array filled with both RecipientVariables from the Mail Class and/or plain emails ["user","[email protected]"]
attachments json (translatable) work in progress
design string A design from config mail-template-engine.designs statikbe::mail.designs.default
render_engine string A render engine from config mail-template-engine.render_engines html
created_at timestamp
updated_at timestamp
deleted_at timestamp

If your application is using Nova you can use Nova Mail Editor: a tool for editing and creating mail templates.

Calling the mail class

In order to send mails you provide the content and recipient variables, and then send Mail object.
The mail object will now look for any mail template in the database using this Mail class, build it and send the mail.

An example:

Content variables

In this array you assign the values to each key used in the mail template(s). You define the recipients in getContentVariables in your mail class. Wrapping the content variables with a locale as key is optional.

Recipient variables

In this array you assign the mail and locale for each recipient in the mail template(s). You define the recipients in getRecipientVariables in your mail class. For more options on how to add the recipient variables look at \Statikbe\LaravelMailEditor\AbstractMail::formatRecipientArray.

Attachment variables

In this array you assign the attachment for each recipient in the mail template(s). You define the recipients in getRecipientVariables in your mail class. For more options on how to add the recipient variables look at \Statikbe\LaravelMailEditor\AbsractMail::formatRecipientArray. Wrapping the attachments with a locale as key is optional.

Styling

The default design provided by the package comes from here. You can publish the views and customise it all you want!

You can provide your own designs by adding them to the designs array in the config. Designs are view directories where you store the views for your render engines, F.E. the default HTML engine expects a view called html.blade.php.

Configuration

You can publish the configuration by running this command:

The following configuration fields are available:

TODO document configuration

License

The MIT License (MIT). Please see license file for more information.


All versions of laravel-mail-template-engine with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1
illuminate/mail Version ^10.0
illuminate/console Version ^10.0
illuminate/bus Version ^10.0
spatie/laravel-translatable Version ^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 statikbe/laravel-mail-template-engine contains the following files

Loading the files please wait ....