我正在使用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)
我無法弄清楚問題出在哪裏?是語法錯誤嗎?或者可能是錯的?
它過去正常工作,現在它已停止。
謝謝!
什麼'Mailgun'?那是laravel的Mail嗎? –
@LionelChan:http://www.mailgun.com/ –
不,我知道什麼是mailgun。這是一個郵件服務。我的意思是你怎麼通過'Mailgun :: send'發送郵件,而不是'Mail :: send'? –