Download the PHP package twindots/email-service without Composer
On this page you can find all versions of the php package twindots/email-service. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download twindots/email-service
More information about twindots/email-service
Files in twindots/email-service
Package email-service
Short Description Compile shortcodes and send emails from predefined templates.
License
Informations about the package email-service
Email service plugin for laravel 5|6|7|8
This package simplify compiling shortcodes and sending emails.
Requirements
Installation
Install this package with composer:
Service Provider & Facade will be discovered automatically by laravel. Publish the config file and views folder: (required)
This will publish the following:
- config/email_service.php
- views/email_service/views.blade.php
- views/email_service/layout.blade.php
- views/email_service/partials/
Usage
This package consist of 2 classes: EmailService and EmailShortCodes.
1- EmailShortCodes:
-
Import the library:
-
Load it in your function:
2- EmailService:
-
Import the library:
-
Load it in your function:
- this library will use the file email_service/view.blade for the email template, you can change it from the config file.
- The
send()
function will return a result array having:- status (boolean): True for success and false for failed delivery.
- Message (text) : Show the message of a failed delivery.
Shortcodes
Shortcodes are defined inside the config file config/email_service.php under the shortcodes array. You can define shortcodes inside groups in order to load each group for different email templates.
Shortcodes can be inserted in your favorite text editor with this command:
P.S: This library will compile anything inside {}
You can add 3 types of shortcodes:
-
Variable:
-
Function:
-
Blade view:
For the blade view shortcode, you don't need to pass any objects since it will inherit the objects passed from the
$shortcodes->objects()
function.
How to check which objects are required:
If you are working with a large list of shortcodes inside a template with multiple variables and views, you need to know what are the required objects, simply call for the function $shortcodes->objectsNeeded()
, it will return an array that will tell you what objects are needed.
Reference
EmailShortCodes
Methods | Parameters | Definition |
---|---|---|
compile() | - | Will compile the body using the shortcodes list and objects |
body() | String $body | Set the body |
objects() | Array $objects | Set the objects |
group() | String $group | Set the group |
addGroup() | String $group | Add a new group to the group list |
withUser() | - | Add the user shortcode group to the shortcodes list |
getGroup() | - | Return the group |
shortcodes() | - | Return the shortcodes list |
objectsNeeded() | - | Return the objects needed to compile |
EmailService
Methods | Parameters | Definition |
---|---|---|
email() | Array,String $email | Set the recipient email |
replyTo() | String $replyTo | Set replyTo, will override the value in config.mail.reply_to |
cc() | Array,String $cc | Set cc |
bcc() | Array,String $bcc | Set bcc |
body() | String $body | Set the body |
subject() | String $subject | Set the subject |
attach() | Array $attachments | Set the attachments |
send() | - | Send the email |
License
The MIT License (MIT). Please see License File for more information.