Download the PHP package theoafactor/messenger without Composer
On this page you can find all versions of the php package theoafactor/messenger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download theoafactor/messenger
More information about theoafactor/messenger
Files in theoafactor/messenger
Package messenger
Short Description Handles sending email messages to users
License MIT
Informations about the package messenger
Messenger
An email and message sender.
-
Easily sends emails to users
-
Add the project
-
Add the following lines at the top of your project:
-
Create an instance of the Messenger class
-
Send your email.
-
The sendMessage() method takes the following arguments:
- recepient's email address
- email subject
- some extra data in the form of associative array
- the file path of email template to be used
- Of all the arguments, the recepient's email address and email subject are compulsory, while the others are not. But it's a good thing to set these arguments.
Setting Environmental Values
-
You should set the environmental values with .env file at the root of your project. Please use the .env.example file as an example.
-
Create a .env file and copy the sample from .env.example file inside theoafactor/messenger/src directory over.
- Supply the data.
Using Email Templates
-
The package uses a mini template engine. The engine will look for your email template in the root of the directory.
-
Variables are outputted with {{ variable_name }} within the template.
-
Variables data come from the extra data associative array passed to the sendMessage() method. For example, in the code below, we have set the extra data associate array to have the firstname and lastname keys.
- In the email template, we can reference the firstname key by using:
Loops
-
This package uses basic looping mechanism and only supports the foreach loop. To loop through an array in the template, follow the sample below:
-
Remember that the arrayKey comes from the data you passed to the sendMessage() method.
-
Support for nested loops has not been added.
- Support for conditional statements has not been added.
Note
-
This project is actively under development. You may use it for your project. You may also contribute to this project by creating a pull request.
- Please report any security issue as soon as you spot one.