First argument to Stream::create() must be a string error when using Mailgun sdk

Posted 1 month ago by Gabotronix

Hi everybody, I'm using Mailgun php sdk to send batch mails with Mailgun php sdk however I'm getting the following error:

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
    83|
    84|             return $new;
    85|         }
    86|
  > 87|         throw new \InvalidArgumentException('First argument to Stream::create() must be a string, resource or StreamInterface.');
    88|     }
    89|
    90|     /**
    91|      * Closes the stream when the destructed.

  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.

This is my code:

$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
        ]);

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.