Shahmee
Shahmee

Reputation: 299

cURL error 18 error coming in laravel sendgrid driver

Below error coming in sendgrid driver. this is used to work ... suddenly not started to work

exception: "GuzzleHttp\Exception\RequestException"
file: "C:\inetpub\wwwroot\qhse\QHSE_Backend\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php"
line: 186
message: "cURL error 18: transfer closed with 116 bytes remaining to read (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)"

This is the code I'm using to send:

return $this
    ->view('email.action')
    ->subject('demo')
    ->from('[email protected]')
    ->sendgrid([
        'personalizations' => [
            [
                'substitutions' => [
                    ':myname' => 's-ichikawa',
                ],
            ],
        ],
    ])
    ->with(['arr' => $this->data]);

Upvotes: 0

Views: 1200

Answers (2)

Sygmoral
Sygmoral

Reputation: 7181

In my case, I had to simply composer update and the issue went away.

An alternative, as suggested here, is to use http 1.0 instead of http 1.1. In this case, that can be done by editing s-ichikawa/laravel-sendgrid-driver/src/Transport/SendgridTransport.php:post() (assuming you also use this package) to say return $this->client->post($this->endpoint, $payload, ['version' => 1.0]); instead.

(and then of course, somehow moving that edit out of /vendor/, or forking that repository)

Upvotes: 0

Biganashvili
Biganashvili

Reputation: 44

I had the same error. this was due to an invalid API key.

cURL error 18: transfer closed with 116 bytes remaining to read (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) {"exception":"[object] (GuzzleHttp\\Exception\\RequestException(code: 401): cURL error 18: transfer closed with 116 bytes remaining to read (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) at /var/www/my_project/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:201)

Upvotes: 1

Related Questions