为什么此代码在向 mailgun 邮件列表发送电子邮件时出现错误?
$mailgun->sendMessage(MAILGUN_DOMAIN,[
'from' => '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dda9b8aea99daebcb0adb1b8aef3b0bcb4b1baa8b3f3b2afba" rel="noreferrer noopener nofollow">[email protected]</a>',
'to' => MAILGUN_LIST,
'subject' => $subject,
'html' => $body.'<br><br><a href="%unsubscribe_url%">Unsubscribe</a>'
]);
我遇到的 fatal error 如下:
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
最佳答案
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了解更多详情。
我也不确定它是否允许您发送到沙箱下的邮件列表。此外,您的发件人地址还应该具有与沙箱域相同的域。
关于php - Mailgun 参数无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39140281/