Renato
Renato

Reputation: 345

Using Mail::queue with iron.io

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.

Upvotes: 1

Views: 1178

Answers (1)

Tim F
Tim F

Reputation: 349

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.

Upvotes: 3

Related Questions