2016-12-29 43 views
0

我正在使用mailgun幫助我在laravel上發送郵件。Mailgun錯誤'傳遞給API的參數無效

這裏郵件代碼:

$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('[email protected], [email protected], [email protected], [email protected]')) 
      ->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) 

我無法弄清楚問題出在哪裏?是語法錯誤嗎?或者可能是錯的?

它過去正常工作,現在它已停止。

謝謝!

+0

什麼'Mailgun'?那是laravel的Mail嗎? –

+0

@LionelChan:http://www.mailgun.com/ –

+0

不,我知道什麼是mailgun。這是一個郵件服務。我的意思是你怎麼通過'Mailgun :: send'發送郵件,而不是'Mail :: send'? –

回答

1

的這個錯誤告訴一切:)

傳遞給API的參數無效。檢查你的輸入!沙盒子域僅用於測試目的。請在帳戶設置中添加您自己的域名或將地址添加到授權的收件人。

在Mailgun中,沙箱子域僅用於測試。如果您需要真正發送電子郵件,則需要將您的域名添加到您的mailgun acc中,或將授權收件人添加到您的mailgun帳戶設置中。

因此,在這種情況下,你要麼需要添加mydomain.com到您的mailgun白名單域名,或添加[email protected][email protected][email protected][email protected]到白名單中的電子郵件。

相關的文檔:https://help.mailgun.com/hc/en-us/articles/217531258-Authorized-Recipients

相關Q &答:https://laracasts.com/discuss/channels/laravel/sending-emails-with-mailgun