call to undefined function sendgrid curl_init

PHP's cURL extension (ext-curl) is not loaded in the SAPI running sendgrid-php. Install ext-curl for your PHP runtime and restart the web server.

Updated Jul 1, 2026

The short answer

This is a fatal PHP error, not an SMTP/SendGrid API error: the sendgrid-php library calls curl_init() inside php-http-client, but PHP's cURL extension (ext-curl) is not loaded in the SAPI you're running. The fix is to install and enable ext-curl for that PHP runtime (e.g. apt-get install php-curl, or uncomment extension=curl in php.ini), then restart the web server.

The SendGrid\curl_init prefix is misleading: this is not a SendGrid or SMTP error code. It is a standard PHP fatal error raised because the sendgrid-php library tries to call curl_init() and PHP's cURL extension isn't loaded.

Why does the error say SendGrid\curl_init() instead of curl_init()?

SendGrid's HTTP layer lives in a namespace. When PHP resolves an unqualified function call inside a namespace, it first looks for SendGrid\curl_init, and only falls back to the global curl_init if the function exists. When ext-curl is not loaded, no global curl_init exists, so the fallback fails and PHP reports the name it tried first — the namespaced one. You'll see it surface here:

Fatal error: Uncaught Error: Call to undefined function SendGrid\curl_init()
in .../vendor/sendgrid/php-http-client/lib/Client.php:459

So the namespace prefix is a red herring — the real problem is always a missing/disabled cURL extension. (Confirmed in sendgrid-php issue #811.)

What causes "Call to undefined function SendGrid\curl_init()"?

sendgrid/sendgrid depends on sendgrid/php-http-client, which uses cURL for every API call — ext-curl is a hard requirement declared as "ext-curl": "*" in its composer manifest. The error means one of:

  • The cURL extension is not installed for your PHP at all.
  • It's installed but commented out in php.ini.
  • It's enabled for one SAPI but not the one running your code. A very common trap: cURL is enabled for PHP-CLI but not for the Apache/PHP-FPM module serving your site (or vice versa). PHP-CLI and the web SAPI can use different php.ini files.
  • On Windows: an architecture/build mismatch between PHP, the web server, and the extension DLL.

How do I fix "Call to undefined function SendGrid\curl_init()"?

1. Confirm which PHP is missing cURL. Check the exact runtime that throws the error, not just CLI:

<?php
var_dump(extension_loaded('curl')); // false = the problem
echo php_ini_loaded_file(); // tells you which php.ini that SAPI uses

Or from the shell for the CLI runtime:

php -m | grep -i curl

2. Install / enable the extension.

Debian/Ubuntu (match your PHP version):

sudo apt-get install php-curl # or php8.2-curl, etc.

RHEL/CentOS/Alma:

sudo yum install php-curl

Windows / manual php.ini — remove the leading semicolon:

extension=curl ; modern PHP (Linux build often: extension=curl.so)
;extension=php_curl.dll -> extension=php_curl.dll (older Windows)

3. Restart the SAPI that serves your app — this is the step most often missed. Editing php.ini does nothing until you reload the process:

sudo systemctl restart apache2 # or: php8.2-fpm, nginx-fpm, httpd

4. Re-verify extension_loaded('curl') returns true in the same SAPI, then re-run your SendGrid send.

If you installed sendgrid-php manually instead of via Composer, switch to composer require sendgrid/sendgrid — Composer validates the ext-curl requirement at install time and surfaces the missing extension before runtime.

On managed/shared hosting where you can't edit php.ini, ask your host to enable cURL for your account (often toggleable in cPanel under "Select PHP Version" → Extensions).

References

Authoritative sources

DOCS

sendgrid-php issue #811: Call to undefined function SendGrid\curl_init()

DOCS

sendgrid/php-http-client (cURL HTTP client for SendGrid)

DOCS

sendgrid/sendgrid on Packagist (ext-curl requirement)

DOCS

PHP manual: namespaces and function name resolution / fallback to global

FAQ

Common questions

Because the call is made inside SendGrid's namespace. PHP resolves unqualified function names against the current namespace first and only falls back to the global function if it exists. With ext-curl missing, the global curl_init() doesn't exist, so PHP reports the namespaced name it tried. It's still the same missing-extension problem.

Almost always because you enabled it for the wrong SAPI or didn't restart the web server. PHP-CLI and Apache/PHP-FPM can load different php.ini files. Check phpinfo() or extension_loaded('curl') from the actual web request, edit that SAPI's php.ini, then restart Apache or PHP-FPM.

Yes. sendgrid/sendgrid depends on sendgrid/php-http-client, which declares "ext-curl": "*" as a required dependency and uses cURL for every HTTPS call to the SendGrid API. There is no built-in non-cURL transport.

Keep going

Related SendGrid errors

View all errors →

One API, every provider

Stop debugging raw provider errors

Courier connects to your email, SMS, and push providers, handles retries and failover, and surfaces delivery errors in plain language.

Start building freeRead the docs

Last reviewed Jul 1, 2026. Courier is not affiliated with third-party providers; error behavior may vary by implementation.

Multichannel Notifications Platform for SaaS

Products

Platform

Integrations

Customers

Blog

API Status

Subprocessors

© 2026 Courier. All rights reserved.