2016-08-25 33 views
2

爲什麼此代碼在發送郵件到mailgun郵件列表時發生錯誤?Mailgun無效參數

$mailgun->sendMessage(MAILGUN_DOMAIN,[ 

'from'   => '[email protected]', 
'to'   => MAILGUN_LIST, 
'subject'  => $subject, 
'html'   => $body.'<br><br><a href="%unsubscribe_url%">Unsubscribe</a>' 

        ]); 

致命錯誤我得到低於給:

Fatal error: Uncaught Mailgun\Connection\Exceptions\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 domain settings. in C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php:226 Stack trace: #0 C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php(99): Mailgun\Connection\RestClient->responseHandler(Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php(151): Mailgun\Connection\RestClient->send('POST', 'sandboxb676bd53...', Object(GuzzleHttp\Psr7\Stream), Array) #2 C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Mailgun.php(118): Mailgun\Connection\RestClient->post('sandboxb676bd53...', Array, Array) #3 C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Mailgun.php(61): Mailgun\Mailgun->post('sandbox in C:\xampp\htdocs\webapp\vendor\mailgun\mailgun-php\src\Mailgun\Connection\RestClient.php on line 226

回答

2

Uncaught Mailgun\Connection\Exceptions\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 domain settings

如果從沙盒中域發送,那麼你需要配置允許的收件人列表(最多5個用戶)。有關更多詳細信息,請參閱here

我也不確定它是否允許您發送到沙箱下的郵件列表。另外,您的發件人地址也應該與沙箱域具有相同的域。

+0

我已將訂閱列表中的郵件標識添加到授權收件人列表中,但仍會拋出相同的錯誤,我認爲我們不需要在「發件人」地址中使用相同的域。 – user2531123

+0

每當我試圖從沙箱發送一封電子郵件到一個不同的域時,它就會失敗。列表中的收件人是否也被設置爲授權收件人?我不完全確定這是如何工作的。 – timkly

+0

這是正確的答案。 – tfont