Skip to content

SendGrid\Content->__construct Error #591

Description

@gusbemacbe

Issue Summary

I have copied the simple sample of an example and I have replaced text/plain for text/html. But it gave an error of SendGrid\Content->__construct. Remember I am not using Composer. I have already echoed and exported the SendGrid API key to .env.

Steps to Reproduce

  1. I have copied the example from this README.md and replaced something:
<?php

require("sendgrid-php/sendgrid-php.php");

header("Access-Control-Allow-Origin: *");

$from = new SendGrid\Email("Atlética UNISAL", "contato@atleticaunisal.com.br");
$subject = "Sending with SendGrid is Fun";
$to = new SendGrid\Email("Atlética UNISAL", "contato@atleticaunisal.com.br");
$content = new SendGrid\Content("text/html", "and easy to do anywhere, even with PHP");
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = getenv('myapikey');
$sg = new \SendGrid($apiKey);
$response = $sg->client->mail()->send()->post($mail);

echo $response->statusCode();
print_r($response->headers());
echo $response->body();
  1. Here is the error:
[Fri Mar 23 20:20:57 2018] PHP Fatal error:  Uncaught Error: Call to undefined function SendGrid\mb_convert_encoding() in /home/ubuntu/Github/Email-PHP/exemplo 2/sendgrid-php/lib/helpers/mail/Mail.php:729
Stack trace:
#0 /home/ubuntu/Github/Email-PHP/exemplo 2/index.php(11): SendGrid\Content->__construct('text/html', 'and easy to do ...')
#1 {main}
  thrown in /home/ubuntu/Github/Email-PHP/exemplo 2/sendgrid-php/lib/helpers/mail/Mail.php on line 729
[Fri Mar 23 20:20:57 2018] 127.0.0.1:53082 [500]: /exemplo%202 - Uncaught Error: Call to undefined function SendGrid\mb_convert_encoding() in /home/ubuntu/Github/Email-PHP/exemplo 2/sendgrid-php/lib/helpers/mail/Mail.php:729
Stack trace:
#0 /home/ubuntu/Github/Email-PHP/exemplo 2/index.php(11): SendGrid\Content->__construct('text/html', 'and easy to do ...')
#1 {main}
  thrown in /home/ubuntu/Github/Email-PHP/exemplo 2/sendgrid-php/lib/helpers/mail/Mail.php on line 729

Technical details:

  • sendgrid-php Version: 5.6.0
  • PHP Version: 7.2
  • OS: Ubuntu 16.04
  • Installed packages: curl, postfix and soap
  • Curl enabled in php.ini

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions