Question

MailShell.php

<?php

App::uses('AppShell', 'Console/Command');
App::uses('CakeEmail', 'Network/Email');

class MailShell extends AppShell
{

    public function sendMail() {
        $Email = new CakeEmail();
        $Email->from(array('admin@localhost' => 'My Site'));
        $Email->to($this->args[1]);
        $Email->subject($this->args[3]);
        $Email->send($this->args[2]);
    }
}

TestController.php

<?php
App::uses('AppController', 'Controller');

class TestController extends AppController {

    public function index(){
        CakeResque::enqueue('default','CakeResque.Mail', array('sendMail','test@gmail.com','Test Email','Hi this it test email.'));
    }
}

When I am open URL

http://localhost/test/index

Jobs are enqueued properly in default queue see

enter image description here

and when I start workers and after stats looks like below

enter image description here

For every Job It increases Processed Jobs by 1 and Failed Jobs by 2 and email is not send

What is real issue ? Is issue with email sending procedure ? Is issue with CakeResque?

Any Help appreciated

Thank you

Was it helpful?

Solution

While enqueuing jobs from TestController use

CakeResque::enqueue('default',
                    'CakeResque.MailShell',   //difference is here
                     array('sendMail',
                           'test@gmail.com',
                           'Test Email',
                           'Hi this it test email.'));

instead of

CakeResque::enqueue('default',
                    'CakeResque.Mail',                                   
                     array('sendMail',
                          'test@gmail.com',
                          'Test Email',
                          'Hi this it test email.'));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top