Support the ongoing development of Laravel.io →
Configuration Mail Queues

Hello, I am trying to send an email via my web application. It used to work but after the last upgrade of laravel something is breaking up. The message seems to arrive at Iron.io but it is never proccessed..

I have created a subscriber with the following command:


php artisan queue:subscribe u-support http://ptyxiakh.eu1.frbit.net/queue/demo

My routes file contains the following:


Route::post('communication',
array(
	'uses' => 'EmailController@store',
	'as' => 'contact.store'
))->before('csrf');

and


Route::post('queue/demo',function(){


	return Queue::marshal();
});

When I post the data from my form to communication the method store of the EmailController is triggered. Here is the import part and the constructor:


use Workflow\Services\Validation\EmailValidator;


class EmailController extends BaseController {


	protected $validator ;


	public function __construct(EmailValidator $validator){

		$this->validator = $validator;

	}

And bellow the store method:


public function store()
	{
	
	if(!$this->validator->validateForSending(Input::all())){

			return Redirect::route('contact.create')->withErrors($this->validator->errors());

	}
	

	Event::fire('mail.send',['data' => Input::all()]);



	return Redirect::route('contact.create')->with('flash_contact','Successfully sent mail');
	
	

	}

My queue configuration for the production environment contains the following:


'default' => 'iron',

and


'iron' => array(
			'driver'  => 'iron',
			'project' => 'my_project',
			'token'   => 'my_project_token',
			'queue'   => 'u-support',
		),

I have subscribed the event in app/start/global.php as following:


Event::subscribe('Workflow\Services\Handlers\EmailEventHandler');

My EmailEventHandler is the following:


<?php namespace Workflow\Services\Handlers;

use Workflow\Services\Mailers\UserMailer;
use Auth;
use User;
use Queue;

class EmailEventHandler{

protected $mail;

    function __construct(UserMailer $mail){

		/*We instantiate a UserMailer object to get 
		the proper functions to send an email
		*/

            $this->mail=$mail;

		

	}


public function onSend(array $data){

	/*User $user comes from the event firing in the controller
	*/

		 	Queue::push(function($job) use ($data){

		 		$this->mail->send($data);

		 		
		 	});
	 		
}

public function subscribe($events){

/*When the user.signup event is fired the method onSignup is 
running
*/

$events->listen('mail.send','Workflow\Services\Handlers\EmailEventHandler@onSend');

}

} 

My UserMailer which extends the Mailer class is the following:


<?php namespace Workflow\Services\Mailers;

use Auth;
use User;

class UserMailer extends Mailer{

	public function send(array $data){

		
		$view='emails.send';

	
		$dataToSend = ['name' => $data['name'],
						'email' => $data['email'],
						'subject' => $data['subject'],
						'comments' => $data['comments']


		];
		
	$this->receive($dataToSend['subject'],$view,$dataToSend);


	}

}

And finally my Mailer is the following:


<?php namespace Workflow\Services\Mailers;

use Mail;

abstract class Mailer{


public function receive($subject,$view,$data){


		Mail::send($view,$data,
			function($message) use($subject,$data) 
			{

				$message->to('giannhs905@gmail.com')->subject($subject);

			});
	
	}


}

Any idea why this breaks up??

Last updated 2 years ago.
0

johnnemo said:

Hello, I am trying to send an email via my web application. It used to work but after the last upgrade of laravel something is breaking up. The message seems to arrive at Iron.io but it is never proccessed..

Do you see increase of "QUEUE SIZE" value in your Iron account for queue u-support or is 0, which would indicate that Queue:marshal is fired?

Last updated 2 years ago.
0

gecbla said:

johnnemo said:

Hello, I am trying to send an email via my web application. It used to work but after the last upgrade of laravel something is breaking up. The message seems to arrive at Iron.io but it is never proccessed..

Do you see increase of "QUEUE SIZE" value in your Iron account for queue u-support or is 0, which would indicate that Queue:marshal is fired?

Last updated 2 years ago.
0

No I do not...

Last updated 2 years ago.
0

If "MESSAGES ALL TIME" value does't change (increase) that means you have problem sending queue. Try this:

public function onSend(array $data) {
	$mail = $this->mail;

	Queue::push(function($job) use ($mail, $data){
		$mail->send($data);
	});
}

You should put a few debug messages, just to see which part of code is passing/failing!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

johnnemo johnnemo Joined 1 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.