-
Notifications
You must be signed in to change notification settings - Fork 623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method 'mail' not found in SendGrid\Client #424
Comments
Hi @TeodorVecerdi, My apologies, I can not reproduce. Here are the steps I took: mkdir test
cd ./test
code composer.json
{
"require": {
"sendgrid/sendgrid": "~6.0"
}
} code test.php
<?php
// If you are using Composer (recommended)
require 'vendor/autoload.php';
// If you are not using Composer
// require("path/to/sendgrid-php/sendgrid-php.php");
$from = new SendGrid\Email("DX Team", "dx@sendgrid.com");
$subject = "Sending with SendGrid is Fun";
$to = new SendGrid\Email("Elmer Thomas", "elmer.thomas@sendgrid.com");
$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP");
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
print_r($response->headers());
echo $response->body(); php test.php The email was sent successfully. Could you please walk me through your install steps? Thanks! With Best Regards, Elmer |
Thanks for the quick reply, @thinkingserious !
and then php sendemail.php
|
Hi @TeodorVecerdi. It looks like you may have run into this issue: https://stackoverflow.com/questions/34842596/call-to-undefined-function-curl-init-even-it-is-enabled-in-php7 |
@thinkingserious I have installed curl and added it to the path. I don't understand what I should do. |
Now that you have done that, what happens when you do |
|
Ok, that looks good. How about when you run |
The same error |
|
For some reason your install of php7 is not finding curl_init(). Can you try stepping through these steps? |
Here are some other potential solutions:
BTW, what OS are you on? |
I'm on windows, this is my first time doing this. Curl was disabled in php.ini indeed. Thank you for the help @thinkingserious |
Awesome, thanks for following up :) |
Issue Summary
While attempting to run the mail example (The one with the Mail Helper class) I encountered a error.
I have tried both the Composer and the direct library and the same problem occurs.
On this line
$response = $sg->client->mail()->send()->post($mail);
onmail()
I getMethod 'mail' not found in SendGrid\Client
.After that everything falls apart
Steps to Reproduce
Not needed.
Technical details:
The text was updated successfully, but these errors were encountered: