Download the PHP package thinker-g/yii2-hermes-mailing without Composer
On this page you can find all versions of the php package thinker-g/yii2-hermes-mailing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thinker-g/yii2-hermes-mailing
More information about thinker-g/yii2-hermes-mailing
Files in thinker-g/yii2-hermes-mailing
Package yii2-hermes-mailing
Short Description Highly configurable multi-process emailing solution (console command) for yii2.0.
License MIT
Informations about the package yii2-hermes-mailing
Hermes Emailing [v1.0.0]
Highly configurable multi-process emailing solution (console command) for yii2.0.
Installation
1. Downloading
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
You could also download a copy directly from the GitHub project page.
If you do in this way, you'll be needing to setup the directory of alias @thinker_g/HermesMailing
. Here's an example.
In config/main.php, assume that you put yii2-hermes-mailing
folder in extensions/
of your project:
In the example @app
is the app's root alias, which will be replaced by its real path. It could be '@common', '@frontend', '@backend' in an advanced template.
2. Installing
a) Configuring
Edit the configuration file of your console appliction ( console/config/main.php
/ config/console.php
by default) to mount the console command controller.
Please be noticed that modelClass
will be used by the command later to generate the AR model, its default value is app\\models\\HermesMail
.
If you are using a basic yii2.0 template or just want to keep the model in model directory of the console application, you don't need to specify the modelClass
.
Here we assume that we are using the default advanced yii2.0 template. And of course, you can specify any model name as you want.
Set installerMode
to true will enable some helper actions that will only be used during installation.
And it should be set to false (or be removed as false is default) when the command is ready for real usage.
testMode
is a helper option for testing performace and adjusting parameters. When it's enabled, the real "send" operation will randomly return true or false.
Except this, all other operations will be performed normally.
b) Initializing (creating database table and generating AR model)
Be sure that your 'db' application component is functioning, then we can issue the command below to initialize the command.
The default initialization will create a table named hermes_mail
and its corresponding AR model with the name you specifed above.
You should be seeing this if the command is installed successfully and ready for using.
c) Fill up some test data
Up to now your program is ready. You could use the generated AR model anywhere in your code, to insert emails to the queue.
To facilitate testing, you could use email/fill4test
command to prepare(insert) 1000 emails for test.
Let's say we want 500 emails to give a try:
Now let's move on to run something real.
Usage
Check before taking off:
ATTENTION! Please check following items before you run the test. This will ensure your emails inserted above won't be sent out.
- InstallerMode is off. (
installerMode
=> false) - Test mode is on. (
testMode
=> true) - Your "mailer" application component is functioning.
Once the extension is installed, simply use it in your code by :
If you are seeing some output like this, your command is working. And you can deploy it by configuring your crontab.
CRONTAB
Please do not forget to disable testMode
before you setup crontab for real emailing.
Here's an example of crontab seeting for webmaster user.
This setting will start a new emailing process every 10 seconds, every process will work parallely till all mails are sent in the queue.
Advanced Configuration
Under development, coming soon!
This part will cover a batch of interesting features:
- Sending control (Indirect control of memory consumption and execution time.)
- Distributed deployment
- Using dedicated email database service
- Complying spamming rules
- Customization (replacing mailer, AR, etc.)
- Handling events
Please, temporarily, read the property comments in the code for usage of them.