Laravel Mailgun only sends one email instead of two

I have a contact form on my website and I need to send two different emails when someone submits it. The first email should go to the user as a confirmation message. The second email should come to me with the ticket details.

I’m working with Laravel 5.2 and using Mailgun for email delivery. The problem is that only one email gets sent (the one to my address). The confirmation email to the user never arrives. Laravel doesn’t show any errors.

Here’s my current code:

// confirmation email for customer
Mail::send('emails.confirmation_template', ['customer_name' => Input::get('name'), 'message_body' => $messageContent], function ($mail)
{
    $mail->subject('Your inquiry has been received');
    $mail->from('[email protected]', 'Customer Support');
    $mail->to(Input::get('user_email'));
});

// notification email for admin
Mail::send('emails.admin_notification', ['sender_email'=> Input::get('user_email'),'sender_name' => Input::get('name'), 'inquiry_text' => Input::get('message'),'phone_number' =>Input::get('phone')], function ($mail)
{
    $mail->subject('New Customer Inquiry: '.Input::get('subject'));
    $mail->from('[email protected]', Input::get('name'));
    $mail->to('[email protected]');
});

What’s the best way to send both emails successfully?

check your Mailgun logs first - that’s where u’ll see what’s actually happening. laravel 5.2 has some weird quirks with mail queueing, so try adding Mail::failures() after each send to catch any silent fails. sometimes Mailgun’s from address validation causes issues too.

I’ve encountered a similar issue with Laravel 5.2 and Mailgun. The silent failure of the second email often stems from Mailgun’s rate limits or authentication problems, especially when emails are dispatched in quick succession. To mitigate this, try introducing a short delay with a sleep(1) or usleep(500000) between your Mail::send() calls. Additionally, if you’re using Input::get('user_email') without validating it, incorrectly formatted email addresses could lead Mailgun to reject them without any errors being relayed back from Laravel. I recommend wrapping each Mail::send() in try-catch blocks to catch any unexpected exceptions, and also monitor your Mailgun dashboard for logs to determine if the emails reach their service. They may occasionally queue but fail due to domain verification issues.

Had this exact problem with Laravel 5.2 and Mailgun about a year ago. Both emails were using the same from address, so Mailgun treated the second one as a duplicate and dropped it silently. Try changing the from address for one email or add a small variation in the subject line to make them unique. Also, make sure your Mailgun domain is verified for both sender addresses. Switching to queued emails instead of sending them synchronously helped me too - it prevented timing conflicts. You can test this by swapping the order of your Mail::send calls. If the other email stops working, you’ve confirmed the duplicate issue.