1

I'm trying to use the Mail::queue in Laravel 4 without success.

When I run the command:

php artisan queue: subscribe queue_name http://foo.com/queue/push

It is created on my dashboard a subscriber, and also when I access my route queue/send a new queue is sent to Iron.io.

The problem is that I never received the email should be sent when the Mail::queue to be executed.

Look my routes:

<?php
Route::post('queue/push', function() {
        return Queue::marshal();
    });

Route::get('queue/send', function() {
        Mail::queue('emails.teste', array(), function($message) {
                    $message->to('me@mesite.com', 'Renato')->subject('Welcome!');
                });

        return 'Ok';
    });

Is there any configuration beyond queues.php I need to do?

When I change the queue/push (for debug) to accept GET and access the URL, the following error appears:

lluminate\Encryption\DecryptException

Invalid data.

Renato
  • 345
  • 1
  • 5
  • 14
  • Have you configured your mail credentials in `app/config/mail.php`? – zeantsoi Jun 28 '13 at 18:14
  • This properly configured my mail file, if I use Mail::send the email is sent – Renato Jun 28 '13 at 18:16
  • Get rid of the space between "queue: subscribe" – Rob W Jun 28 '13 at 19:47
  • No. Problem is not with my code to send to queue, is receiving – Renato Jun 28 '13 at 19:53
  • 2
    Your code works fine, I've just tested it on my local machine. I only had to add the `->from("email@site.com")` method. Check that: (1) there are no issues with incoming connections (e.g., firewall); (2) you have specified the correct `queue` name in `app/config/queue.php`; (3) `CURLOPT_SSL_VERIFYPEER` in the `IronCore.class.php` class isn't the culprit; (4) there are no other routes that kick in before `Route::post('queue/push'...`. – MrCasual Jun 28 '13 at 23:11

1 Answers1

3

I might be off, but Mail::send() is the correct function to use, since you are using Iron.io to handle the queue.

This should work:

Route::get('queue/send', function() {

    Queue::push(function($job) {

        Mail::send('emails.teste', array(), function($message) {
            $message->to('me@mesite.com', 'Renato')->subject('Welcome!');
        });

        $job->delete();
    }

    return 'Ok';
});

I'd also suggest checking your Iron.io account to ensure that the 'subscriber' URL is set-up correctly. As Rob W suggests, the space could be causing issues.

Tim F
  • 349
  • 1
  • 12
  • I also thought there was supposed to be a class with a `fire` method in it. I don't use queue's enough... – Rob W Jun 28 '13 at 20:28
  • Typically you would. For simple tasks like sending out an email, a class might be overkill. L4 also supports pushing a closure onto the queue - [Queueing Closures](http://laravel.com/docs/queues#queueing-closures) – Tim F Jun 28 '13 at 20:36
  • 3
    @timF `Mail:queue` (http://laravel.com/docs/mail#queueing-mail) works with `Iron.io` – MrCasual Jun 28 '13 at 23:07
  • @TimF I just deleted my account and recreated the same Queue in Iron.io and everything worked. VERY strange, if someone go through it, do not waste too much time, delete and recreate the URL in dashboard Iron.io – Renato Jun 30 '13 at 01:52