Mailgun错误'传递给API的参数无效

时间:2016-12-29 01:23:06

标签: laravel laravel-5 mailgun

我正在使用mailgun来帮助我在laravel上发送邮件。

这里是邮件代码:

$data = array('name' => ucfirst($customer_name),'email' => $email, 'ticket_id' => $ticket_id);
$mail_data = array('name' => ucfirst($customer_name),'email' => $email, 'mobile' =>  $contact, 'address' => $address, 'delivery_type' => ucfirst(Input::get('delivery_type')), 'pickup_type' => ucfirst(Input::get('pickup_type')), 'pickup_date' => $pickup_date, 'pickup_time' => $pickup_time, 'brand' => $brand_name, 'ticket_id' => $ticket_id, 'city' => $region_name);

Mailgun::send('emails.ticket', $mail_data , function($message) use($data)
{
  $message->to($data['email'], $data['name'])
          ->bcc(array('myemail@mydomain.com, aotheremail@mydomain.com, onemore@mydomain.com, lastone@mydomain.com'))
          ->subject('Service Request! - '.$data['ticket_id']);
            });

我检查了发现的日志:

[2016-12-29 05:58:58] production.ERROR: exception 'Mailgun\Connection\Exceptions\MissingRequiredParameters' with message '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.' in /var/www/html/mysite/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php:169
Stack trace:
#0 /var/www/html/mysite/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(88): Mailgun\Connection\RestClient->responseHandler(Object(GuzzleHttp\Message\Response))
#1 /var/www/html/mysite/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(106): Mailgun\Connection\RestClient->post('sandbox798d350d...', Array, Array)
#2 /var/www/html/mysite/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(53): Mailgun\Mailgun->post('sandbox798d350d...', Array, Array)
#3 /var/www/html/mysite/vendor/bogardo/mailgun/src/Bogardo/Mailgun/Mailgun.php(104): Mailgun\Mailgun->sendMessage('sandbox798d350d...', Array, Array)
#4 /var/www/html/mysite/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(222): Bogardo\Mailgun\Mailgun->send('emails.ticket', Array, Object(Closure))
#5 /var/www/html/mysite/app/Http/Controllers/AppController.php(384): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#6 /var/www/html/mysite/app/Http/Controllers/AppController.php(384): Bogardo\Mailgun\Facades\Mailgun::send('emails.ticket', Array, Object(Closure))
#7 [internal function]: App\Http\Controllers\AppController->pickup_request()
#8 /var/www/html/mysite/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(256): call_user_func_array(Array, Array)
#9 /var/www/html/mysite/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(164): Illuminate\Routing\Controller->callAction('pickup_request', Array)

我无法确定问题所在?这是语法错误吗?或者什么可能是错的?

现在它已经停止了。

谢谢!

1 个答案:

答案 0 :(得分:1)

错误告诉所有事情:)

  

传递给API的参数无效。检查你的输入!沙箱子域仅用于测试目的。请在“帐户设置”中添加您自己的域或将地址添加到授权收件人。

在Mailgun中,沙箱子域仅用于测试。如果您需要真正发送电子邮件,则需要将您的域名添加到您的mailgun acc中,或将授权的收件人添加到您的mailgun帐户设置中。

因此,在这种情况下,您需要将mydomain.com添加到邮件列入白名单的域中,或添加myemail@mydomain.comaotheremail@mydomain.comonemore@mydomain.comlastone@mydomain.com进入白名单的电子邮件。

相关文档:https://help.mailgun.com/hc/en-us/articles/217531258-Authorized-Recipients

相关问答:https://laracasts.com/discuss/channels/laravel/sending-emails-with-mailgun