-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,58 @@ | ||
CakePHP-Mailqueue-Plugin | ||
======================== | ||
|
||
Plugin to store maile in a queue for later sendout | ||
Plugin to store mail in a queue for later sendout. | ||
|
||
When working with emails on a webservice sending email blocks the http request until the email is actually sent out. This can be frustrating for a user especially if the smtp server does not respond promptly. | ||
|
||
With this plugin you can save the mail to a local queue file and invoke the actual transport for example with a cron fired cake shell command. | ||
|
||
Installation | ||
------------- | ||
|
||
Download the plugin to app/Plugin/Mailqueue. | ||
|
||
Configuration | ||
------------- | ||
|
||
Add a new entry to the app/Config/email.php or replace it with an existing one. | ||
|
||
```php | ||
class EmailConfig | ||
{ | ||
public $queue = array( | ||
// required: | ||
'transport' => 'Mailqueue.Queue', | ||
'from' => '[email protected]', | ||
// optional: | ||
'queueFolder' => '/tmp/mailqueue' // storage location for mailqueue | ||
); | ||
|
||
// Your exiting config | ||
public $smtp = array(...) | ||
} | ||
``` | ||
|
||
Queue a mail | ||
------------ | ||
|
||
Send mail to the queue as usually in cake | ||
|
||
```php | ||
App::uses('CakeEmail', 'Network/Email'); | ||
$email = new CakeEmail('queue'); | ||
// place your content in $email | ||
$email->send(); | ||
``` | ||
|
||
Do the real sendout | ||
------------------- | ||
|
||
Use cake shell to do the real sendout. The shell script requires 2 arguments. The first is the name of your queue configuration and the second the name of the config to use for the real sendout. | ||
|
||
In your app directory execute: | ||
|
||
```sh | ||
Console/cake Mailqueue.SendMail queue smtp | ||
``` | ||
|