2016-08-25 32 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