Php 使用Mailgun sdk时,Stream::create()的第一个参数必须是字符串错误
我正在使用Mailgun php sdk发送带有Mailgun php sdk的批处理邮件,但出现以下错误:Php 使用Mailgun sdk时,Stream::create()的第一个参数必须是字符串错误,php,laravel,Php,Laravel,我正在使用Mailgun php sdk发送带有Mailgun php sdk的批处理邮件,但出现以下错误: InvalidArgumentException : First argument to Stream::create() must be a string, resource or StreamInterface. at C:\xampp\htdocs\dtcburger.com\vendor\nyholm\psr7\src\Stream.php:87 Exception
InvalidArgumentException : First argument to Stream::create() must be a string, resource or StreamInterface.
at C:\xampp\htdocs\dtcburger.com\vendor\nyholm\psr7\src\Stream.php:87
Exception trace:
1 Nyholm\Psr7\Stream::create(Object(Illuminate\Support\Collection))
C:\xampp\htdocs\dtcburger.com\vendor\nyholm\psr7\src\Factory\HttplugFactory.php:29
2 Nyholm\Psr7\Factory\HttplugFactory::createStream(Object(Illuminate\Support\Collection))
C:\xampp\htdocs\dtcburger.com\vendor\php-http\multipart-stream-builder\src\MultipartStreamBuilder.php:61
Please use the argument -v to see more details.
这是我的代码:
$mailgun = Mailgun::create(env('MAILGUN_SECRET'));
$result = $mailgun->sendMessage(config('mail.mailgunDomain'), [
'from' => config('mail.username'),
'to' => $emails,
'subject' => $mailData['subject'],
'text' => 'Hi',
'recipient-variables' => $json
]);
我收到了相同的错误,经过一些调试后,发现无法找到内联映像 因此,请检查您的案例中是否填写了所有参数,只需执行以下操作:
var_dump(config('mail.mailgunDomain'), [
'from' => config('mail.username'),
'to' => $emails,
'subject' => $mailData['subject'],
'text' => 'Hi',
'recipient-variables' => $json
]);exit;
env('MAILGUN\u SECRET')
为您返回了什么?从错误消息中,很明显它不是一个字符串。只是检查了一下,它是一个字符串。我得到了这个确切的错误消息,发现我发送给Mailgun的数组中有Mailgun不知道如何处理的其他变量。确保构建要发送的数组中没有Mailgun不期望的元素,并且字符串字段实际上是字符串而不是数组。我会让它保持简单,并手动输入数组值(from、to、subject、text)作为测试用例,看看错误是否消失。