php - Mailgun 参数无效

标签 php api mailgun

为什么此代码在向 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/

相关文章:

javascript - 脚本和样式未在 functions.php 中排队

php - Symfony 有 OpenID 2.0 插件吗?

php - 根据 Woocommerce 中的自定义购物车项目数据自定义购物车项目小计

javascript - Handlebars 不渲染 x :mailgun variables passed to custom templates through AWS lambda 中的对象 Prop 和数组

smtp - Mailgun 递送状态 602 - 太旧

php - 将 PHP 变量传递给 MySQL 数据库

python - 使用 Python 的请求对表单数据进行 POST 请求

c++ - 使用手动 CreateFile() 复制单个大文件(>100 MB)

java - Api 21 上的工具栏项 MaterialButton 中的颜色错误

Mailgun:电子邮件转发不起作用?