mardi 29 décembre 2015

Simplest way to use Mail::queue with Laravel 5, IronMQ?

I've read other posts on StackOverflow and elsewhere on using Laravel mail and IronMQ, e.g. Using Mail::queue with iron.io - they either advocate using Queue::push and Mail::send together, or else say you can use Mail::queue but don't provide specific examples of code.

Is it possible to queue emails with just Mail::queue? (i.e. without using Queue::push?)

I've tried with the code below, but Mail::queue here doesn't actually send a message to Iron (my other settings should be OK as I can see Queue::push works, and Mail::send works too just without the queue getting involved)

public function submit_contact_form()
{
        ContactForm::create(['email'=>$_POST['email'],'query'=>$_POST['query'],'name'=>$_POST['name']]);
   $name_fixed = ucwords(strtolower($_POST['name']));
 $data = array('name'=>$name_fixed, 'query'=>$_POST['query']);
    Mail::queue('emails.contact_form', $data, function($message) {
        $name_fixed = ucwords(strtolower($_POST['name']));
        $message->to($_POST['email'], $name_fixed)->subject('Contact received');
    });

}


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

So to sum up, what's the simplest / most efficient way to use Iron queues with Laravel 5 mail?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Slj47K
via IFTTT

Aucun commentaire:

Enregistrer un commentaire