PHP code example of crabstudio / email-queue

1. Go to this page and download the library: Download crabstudio/email-queue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

crabstudio / email-queue example snippets


// In src/PostsController.php

public function send_email($id) {
	$post = $this->Posts->get($id);
	$result = enqueue(
		'[email protected]',
		[
			'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',

		],
		'[email protected]',
		'[email protected]',
		'[email protected]'
	);
	if ($result) {
		$this->Flash->success(__('Enqueue email ok'));
	} else {
		$this->Flash->error(__('Enqueue email not ok'));
	}
}