2017 © Pedro Peláez
 

cakephp-plugin email-queue

EmailQueue plugin for CakePHP 3.x

image

crabstudio/email-queue

EmailQueue plugin for CakePHP 3.x

  • PHP
  • 0 Dependents
  • 5 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

EmailQueue plugin for CakePHP 3

Note

This plugin base on Lorenzo cakephp-email-queue but with little bit different:, (*2)

- Sent to `one|multiple` people
- CC to `none|one|multiple` people
- BCC to `none|one|multiple` people
- Included helpers `Html, Text, Number`

Installation

You can install this plugin into your CakePHP application using composer., (*3)

composer require crabstudio/email-queue

Then load this plugin by type in your command line:

bin/cake plugin load EmailEnqueue --bootstrap

or paste this line to the end of config/bootstrap.php, (*4)

Plugin::load('EmailQueue', ['bootstrap' => true]);

Create required table

2 way to do it, (*5)

Use Migration tool

bin/cake migrations migrate --plugin EmailQueue

Load sql file into your database

sql file located at: config/schema/email_queue.sql

Usage

Call enqueue function anywhere you want to store new email in the queue.

/**
 * Stores a new email message in the queue.
 *
 * @param mixed|array $to           email or array of emails as recipients
 * @param array $data    associative array of variables to be passed to the email template
 * @param array $options list of options for email sending.
 *
 * $options Possible keys:
 * - subject : Email's subject
 * - send_at : date time sting representing the time this email should be sent at (in UTC)
 * - template :  the name of the element to use as template for the email message
 * - layout : the name of the layout to be used to wrap email message
 * - format: Type of template to use (html, text or both)
 * - config : the name of the email config to be used for sending
 * @param null|mixed|array $cc           null or email or array of emails as cc
 * @param null|mixed|array $bcc          null or email or array of emails as bcc
 * @param null|mixed|array $reply_to     null or email or array of emails as reply_to
 *
 * @return bool
 */
enqueue($to, array $data, array $options = [], $cc = null, $bcc = null, $reply_to = null)

Example, (*6)

// In src/PostsController.php

public function send_email($id) {
    $post = $this->Posts->get($id);
    $result = enqueue(
        'customer@crabstudio.info',
        [
            'post' => $post,
            'request' => $this->request
        ],
        [
            'subject' => __('New post notification'),
            'format' => 'html',
            'template' => 'Post/new_post_notification',  //template located here src/Template/Email/html/Post/new_post_notification.ctp
            'layout' => 'notification' //layout located here src/Template/Layout/Email/html/notification.ctp
            'config' => 'default',

        ],
        'cc_to_me@crabstudio.info',
        'bcc_to_you@crabstudio.info',
        'reply_to_support@crabstudio.info'
    );
    if ($result) {
        $this->Flash->success(__('Enqueue email ok'));
    } else {
        $this->Flash->error(__('Enqueue email not ok'));
    }
}

Schedule task

Linux:

Open crontab then setup cronjob like this:, (*7)

*       *       *       *       *       cd /var/www/your_project && bin/cake EmailQueue.sender

Windows:

Open Task Scheduler then follow this tutorial, (*8)

The Versions

22/02 2017

dev-master

9999999-dev https://github.com/crabstudio/emailqueue

EmailQueue plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

email cakephp crabstudio anhtuank7c bulk email cakephp 3

22/02 2017

1.0.6

1.0.6.0 https://github.com/crabstudio/emailqueue

EmailQueue plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

email cakephp crabstudio anhtuank7c bulk email cakephp 3

16/05 2016

1.0.5

1.0.5.0 https://github.com/crabstudio/emailqueue

EmailQueue plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

email cakephp crabstudio anhtuank7c bulk email cakephp 3

20/04 2016

1.0.4

1.0.4.0 https://github.com/crabstudio/emailqueue

EmailQueue plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

email cakephp crabstudio anhtuank7c bulk email cakephp 3

19/04 2016

1.0.3

1.0.3.0 https://github.com/crabstudio/emailqueue

EmailQueue plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

email cakephp crabstudio anhtuank7c bulk email cakephp 3

19/04 2016

1.0.2

1.0.2.0 https://github.com/crabstudio/emailqueue

EmailQueue plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

email cakephp crabstudio anhtuank7c bulk email cakephp 3

18/04 2016

1.0.1

1.0.1.0 https://github.com/crabstudio/emailqueue

EmailQueue plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

email cakephp crabstudio anhtuank7c bulk email cakephp 3

15/04 2016

1.0.0

1.0.0.0 https://github.com/crabstudio/emailqueue

EmailQueue plugin for CakePHP 3.x

  Sources   Download

MIT

The Requires

 

The Development Requires

email cakephp crabstudio anhtuank7c bulk email cakephp 3