Support the ongoing development of Laravel.io →
Mail Queues

I'm using Laravel 4.2, IronMQ and Mailgun to send emails on the live site. For some reason two - sometimes three - copies of the email are being sent, about two minutes apart.

Mail::queue(
	$templates,
	$template_data,
	function($message) use ($template, $parameters, $recipient) {

		// Address the message.
		$message->to( $recipient )
		        ->subject( $parameters['subject'] );

		// Add any additional recipients.
		if ( isset($parameters['reply-to']) )
		{
			$message->replyTo( $parameters['reply-to'] );
		}
		if ( isset($parameters['cc']) )
		{
			$message->cc( $parameters['cc'] );
		}
		if ( isset($parameters['bcc']) )
		{
			$message->bcc( $parameters['bcc'] );
		}

		// Add any attachments to the email.
		if ( isset($parameters['attach']) )
		{
			if ( is_array($parameters['attach']) )
			{
				foreach ($parameters['attach'] as $file)
				{
					$message->attach( $file );
				}
			}
			else
			{
				$message->attach( $parameters['attach'] );
			}
		}

	});

In my development environment I use sync for queuing, which doesn't appear to have the same issue.

My question is: how can I prevent the emails being sent more than once?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.