Invalid API Parameters Error When Using Mailgun with Laravel

I’m getting an error when trying to send emails through Mailgun in my Laravel application. The error message says the API parameters are invalid and mentions something about sandbox subdomains being for test purposes only.

$user_info = array('full_name' => ucfirst($client_name), 'user_email' => $user_email, 'order_id' => $order_number);
$email_content = array('full_name' => ucfirst($client_name), 'user_email' => $user_email, 'phone' => $phone_number, 'location' => $user_address, 'service_type' => ucfirst(Input::get('service_type')), 'appointment_type' => ucfirst(Input::get('appointment_type')), 'scheduled_date' => $appointment_date, 'scheduled_time' => $appointment_time, 'company' => $company_name, 'order_id' => $order_number, 'region' => $area_name);

Mailgun::send('emails.order_confirmation', $email_content, function($msg) use($user_info)
{
  $msg->to($user_info['user_email'], $user_info['full_name'])
      ->bcc(array('[email protected], [email protected], [email protected]'))
      ->subject('Order Confirmation - '.$user_info['order_id']);
});

The error log shows: MissingRequiredParameters: The parameters passed to the API were invalid. Check your inputs! Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings.

This was working fine before but suddenly stopped. What could be causing this issue?

Had this exact issue a few months back - drove me crazy for hours. You’re almost definitely still using Mailgun’s sandbox domain instead of your verified custom domain. Here’s what happens: you start with sandbox for testing, everything works great, then Mailgun restricts sandbox usage and you need your own domain. Check your Mailgun dashboard - did you add and verify your actual domain? If not, add it and update your DNS with the TXT and CNAME records they give you. Once it’s verified, update MAILGUN_DOMAIN in your .env file to use your custom domain, not the sandbox. Also make sure recipient emails are either on your verified domain or added to authorized recipients if you’re still testing.

That error indicates you’re still using Mailgun’s sandbox domain, which blocks most emails. I encountered this exact issue during deployment when I forgot to switch to my real domain. Verify your Mailgun settings to ensure your actual domain is added and confirmed. Also, update the TXT and CNAME records in your DNS settings accordingly. After that, ensure your Laravel configuration points to the verified domain instead of the sandbox. Additionally, check that any BCC addresses in your code are either verified or included in your authorized recipients list.

yup, def still on the sandbox. just check your .env file and see if MAILGUN_DOMAIN has that sandbox thingy. make sure u got ur real domain in Mailgun dashboard. usually that’s what messes things up!