Sendgrid-php: Updating from SendGrid V2 API to V3

Created on 3 Jul 2017  Β·  46Comments  Β·  Source: sendgrid/sendgrid-php

Issue Summary

I'm trying to update my website, hosted on a 3rd party server, from V2 SendGrid API to V3. I downloaded the zip package from GitHub and unpacked into my testing area on my local Windows PC. I wrote a simple test application based upon code as in https://github.com/sendgrid/sendgrid-php#usage "Hello Email" example, only modifying the to and from data and adding the API key I downloaded earlier. I don't use composer as I don't know if it is installed on the 3rd party and I don't have access to command line. The example implies that you don't need composer.

I assume that I have to delete the entire contents of the V2 sendgrid-php folder and replace it with the files downloaded from GitHub - there does not appear to be any documentation on this. There are no instructions otherwise here https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html

If I run the app I get the error as in step 1 below

If I look in the sendgrid-php there is no vendor folder

I then copied the vendor folder from my V2 download into the sendgrid-php folder

Steps to Reproduce

Step 1 - Install library from GitHub exactly as unpacked

Install the library
Add the API Key to the example
Change e-mail addresses to ones that should work
Run app
Error

Warning: require(........sendgrid-php/vendor/autoload.php): failed to open stream: No such file or directory in .........sendgrid-phpsendgrid-php.php on line 2

Fatal error: require(): Failed opening required '...........sendgrid-php/vendor/autoload.php' (include_path='.;C:phppear') in .........................................sendgrid-phpsendgrid-php.php on line 2

Step 2 - Install library from GitHub with additional vendor folder

Install the library
Add the vendor folder from V2
Add the API Key to the example
Change e-mail addresses to ones that should work
Run app
Error

Fatal error: Uncaught Error: Class 'SendGridEmail' not found in ............php:93 Stack trace: #0 {main} thrown in ............php on line 93

In the V2 folder there is a SendGrid/Mail.php in the lib folder. In the V3 folder there is a SendGrid.php file but no SendGrid folder with an Email.php file

I don't think I want to do any more fiddling with the code. I'm surprised that doing something as basic as this causes these sort of errors

Having looked at the documentation I hope that the library provides a simpler method of handling attachments than described. Like on of your other correspondents, I've too much to do to worry about digging in the depths of the API. I want to just be able to use a straightforward interface - which the V2 API provided

Technical details:

  • sendgrid-php Version: master (latest commit: 6.0.0 as in changelog.md)
  • PHP Version: 7.1.3
help wanted question

All 46 comments

Hi @ianh2,

Instead of including vendor/autoload.php, could you please instead try including this file in your test project?

Thanks!

Elmer

Hi Elmer

I modified the sendgrid-php.php file from

require __DIR__ . '/vendor/autoload.php';

?>

To

/**

  • Allows us to include one file instead of two when working without composer.

*/

require_once __DIR__ . '/SendGrid.php';

require_once __DIR__ . '/helpers/mail/Mail.php';?>

I ran my test file (based on your example) and got the following in my server's error log

[Tue Jul 04 09:13:18 2017] [error] [client 82.69.11.147:34358] AH01215: PHP Warning: require_once(/home/sites/.../public_html/sendgrid-php/SendGrid.php): failed to open stream: No such file or directory in /home/sites/.../public_html/sendgrid-php/sendgrid-php.php on line 5: /home/sites/..../public_html/testarea/...TestMail.php

[Tue Jul 04 09:13:18 2017] [error] [client 82.69.11.147:34358] AH01215: PHP Fatal error: require_once(): Failed opening required '/home/sites/.../public_html/sendgrid-php/SendGrid.php' (include_path='.:/usr/share/pear55:/usr/share/php') in /home/sites/.../public_html/sendgrid-php/sendgrid-php.php on line 5: /home/sites/.../public_html/testarea/...TestMail.php

There's no SendGrid.php file in the sendgrid-php folder or no helpers folder so I altered sendgrid-php.php to

/**

  • Allows us to include one file instead of two when working without composer.

*/

require_once __DIR__ . '/lib/SendGrid.php';

require_once __DIR__ . '/lib/helpers/mail/Mail.php';?>

This took me a bit further and I got the following error - this was displayed on the web page

Fatal error: Class 'SendGridClient' not found in /home/sites/.../public_html/sendgrid-php/lib/SendGrid.php on line 53

There is no 'Client.*' file in the GitHub download

Note that the V2 sendgrid-php.php is as follows and that works with no problems

require 'vendor/autoload.php';

require 'lib/SendGrid.php';

?>

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 04 July 2017 00:46
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Hi @ianh2 https://github.com/ianh2 ,

Instead of including vendor/autoload.php, could you please instead try including this file https://github.com/sendgrid/sendgrid-php/blob/master/lib/loader.php in your test project?

Thanks!

Elmer

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-312750601 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6nSix3qPvwbTl0HQH8cj-qpvM5lLks5sKX0ZgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6vFtrh97syUxTsWl-cULe0IQwv4kks5sKX0ZgaJpZM4OL-VK.gif

Hi @ianh2,

It sounds like you may be trying to use v2 with v3. This SDK will not work with v2. You need to choose one or the other. Please remove all files relating to v2, download this SDK, then try my suggestion.

I hope that helps!

With Best Regards,

Elmer

So what you're saying is that there is no transition available in the change from V2 to V3? This means that I cannot convert my pages one at a time. I have to install V3 and hope that everything works first time?

Cannot I create a sendgrid3 folder and change the reference for each page that needs changing? This would allow a graceful transition.

A lack of any sort of backward compatibility or transition does seem to indicate user unfriendly software

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 04 July 2017 13:53
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Hi @ianh2 https://github.com/ianh2 ,

It sounds like you may be trying to use v2 with v3. This SDK will not work with v2. You need to choose one or the other. Please remove all files relating to v2, download this SDK, then try my suggestion.

I hope that helps!

With Best Regards,

Elmer

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-312870447 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6s39LW4uK_c2uHVZ8UPoVtjRFND_ks5sKjWdgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6q4RRsic4QQCM0ZR6X9MEYK4vFFDks5sKjWdgaJpZM4OL-VK.gif

I did the following

  1. Removed the sendgrid-php folder and its contents from the live server (hoping that no-one would want to use a mail function)

  2. Uploaded the contents of the GitHub download to a new sendgrid-php folder

  3. Amended the sendgrid-php.php file as recommended in your e-mail

  4. Modified the sendgrid-php.php file to prefix both require targets with "/lib"

  5. Ran the program

Same error as before

Fatal error: Class 'SendGridClient' not found in /home/sites/...../public_html/sendgrid-php/lib/SendGrid.php on line 53

As I said before there is no "Client" folder or file in the GitHub V3 download. There is a "clients" in examples

Ian

PS I then reinstated V2 and deleted V3 and all is back to normal

From: Elmer Thomas [mailto:[email protected]]
Sent: 04 July 2017 13:53
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Hi @ianh2 https://github.com/ianh2 ,

It sounds like you may be trying to use v2 with v3. This SDK will not work with v2. You need to choose one or the other. Please remove all files relating to v2, download this SDK, then try my suggestion.

I hope that helps!

With Best Regards,

Elmer

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-312870447 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6s39LW4uK_c2uHVZ8UPoVtjRFND_ks5sKjWdgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6q4RRsic4QQCM0ZR6X9MEYK4vFFDks5sKjWdgaJpZM4OL-VK.gif

@ianh2,

Thanks for the follow up. I see the issue now. You are missing this dependency: https://github.com/sendgrid/php-http-client.

I will need to update the non-composer install instructions, this is now on our backlog.

Thanks!

With Best Regards,

Elmer

OK - I'll have a go at retrying later on

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 05 July 2017 16:55
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

@ianh2 https://github.com/ianh2 ,

Thanks for the follow up. I see the issue now. You are missing this dependency: https://github.com/sendgrid/php-http-client.

I will need to update the non-composer install instructions, this is now on our backlog.

Thanks!

With Best Regards,

Elmer

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-313145869 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6v_1XpyXpMOF_BnJCHUmP38pg9zqks5sK7HDgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6kXRk0icQ0PXKJ9b5ka6Vw1B9lkgks5sK7HDgaJpZM4OL-VK.gif

Elmer

I'm not sure you do!

I managed to get back to the error by doing

  1. Clear the contents of the sendgrid-php folder

  2. Copy in the original Git Hub download

  3. Copy on top, the link you refer to below

If you don't do this then at least the following files are missing from your new download

sendgrid-php.php

lib/SendGrid.php

  1. This gives an error, so I modified the sendgrid-php.php file as stated yesterday

/**

  • Allows us to include one file instead of two when working without composer.

*/

require_once __DIR__ . '/lib/SendGrid.php';

require_once __DIR__ . '/lib/helpers/mail/Mail.php';

Without the /lib, it fails to find the file

  1. Having done this, I get the same error as yesterday

Fatal error: Class 'SendGridClient' not found in /home/sites/...../public_html/sendgrid-php/lib/SendGrid.php on line 53

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 05 July 2017 16:55
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

@ianh2 https://github.com/ianh2 ,

Thanks for the follow up. I see the issue now. You are missing this dependency: https://github.com/sendgrid/php-http-client.

I will need to update the non-composer install instructions, this is now on our backlog.

Thanks!

With Best Regards,

Elmer

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-313145869 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6v_1XpyXpMOF_BnJCHUmP38pg9zqks5sK7HDgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6kXRk0icQ0PXKJ9b5ka6Vw1B9lkgks5sK7HDgaJpZM4OL-VK.gif

'SendGridClient' is contained in this dependency: https://github.com/sendgrid/php-http-client

Yes but not SendGrid.php. I installed SendGrid.php from the original download

The Client was installed in the test system. Is it not expecting to find a file "Clint" in a "SendGrid" folder?

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 05 July 2017 19:53
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

'SendGridClient' is contained in this dependency: https://github.com/sendgrid/php-http-client

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-313193643 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6taryYLK2E86pKGqEeE_0iiuEYbXks5sK9t3gaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6ln_rZe6i2tTwPJQUQJD1bXMsa85ks5sK9t3gaJpZM4OL-VK.gif

Hi @ianh2,

I want to try and reproduce the error locally. Can you please tell me the directory structure of your code. Even better if you can share the relevant codebase with me at [email protected]. At least enough to try and reproduce the error.

With Best Regards,

Elmer

Hi Elmer

I've sent you all relevant files in an email to the address you provided. It does contain a zip file which might get spam trapped

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 06 July 2017 00:46
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Hi @ianh2 https://github.com/ianh2 ,

I want to try and reproduce the error locally. Can you please tell me the directory structure of your code. Even better if you can share the relevant codebase with me at [email protected]. At least enough to try and reproduce the error.

With Best Regards,

Elmer

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-313256573 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6hwRdbXNsEtQzOch9PYacAWeZYuIks5sLCA0gaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6t-CwDaVtUhlgN3xuoHkesOVHCPlks5sLCA0gaJpZM4OL-VK.gif

Hi @ianh2,

I have just responded via email, please try out my suggestion and let me know how it goes. Thanks!

Hi ElmerΒ 
Sorry but I can't do anything today as I've got to go to see a client
Will look tomorrowΒ 
Ian
-------- Original message --------From: Elmer Thomas notifications@github.com Date: 06/07/2017 23:23 (GMT+00:00) To: sendgrid/sendgrid-php sendgrid-php@noreply.github.com Cc: ianh2 ian@ianhenderson.me.uk, Mention mention@noreply.github.com Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
Β  (#412)
Hi @ianh2,
I have just responded via email, please try out my suggestion and let me know how it goes. Thanks!

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/sendgrid/sendgrid-php","title":"sendgrid/sendgrid-php","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/sendgrid/sendgrid-php"}},"updates":{"snippets":[{"icon":"PERSON","message":"@thinkingserious in #412: Hi @ianh2,rnrnI have just responded via email, please try out my suggestion and let me know how it goes. Thanks!"}],"action":{"name":"View Issue","url":"https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-313535603"}}}

Great, thanks!

I was wondering if there was any update on this. I myself am having this same issue, where "Class 'SendGridClient' not found". All I have is the base download of the sendgrid-php codebase and I have changed the require statement to: require("sendgrid-php/lib/loader.php");.

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

I was wondering if there was any update on this. I myself am having this same issue, where "Class 'SendGridClient' not found". All I have is the base download of the sendgrid-php codebase and I have changed the require statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314361038 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCgawks5sMyZlgaJpZM4OL-VK.gif

I ran into the same issue. I think that issue with the verification is due
to how you are setting your API key. if you remove the setenv() function
and just hardcode the API key, it should work. But it is not a best
practice to hardcode API keys into your codebase.

On Tue, Jul 11, 2017 at 1:19 AM, ianh2 notifications@github.com wrote:

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification
error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I was wondering if there was any update on this. I myself am having this
same issue, where "Class 'SendGridClient' not found". All I have is the
base download of the sendgrid-php codebase and I have changed the require
statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314361038>
, or mute the thread AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCg
awks5sMyZlgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314370150,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARM2r3GuvHDQNImVmbWzRUn9gwKdTQ2Wks5sMzAvgaJpZM4OL-VK
.

Thanks!

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:24
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

I ran into the same issue. I think that issue with the verification is due
to how you are setting your API key. if you remove the setenv() function
and just hardcode the API key, it should work. But it is not a best
practice to hardcode API keys into your codebase.

On Tue, Jul 11, 2017 at 1:19 AM, ianh2 notifications@github.com wrote:

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification
error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I was wondering if there was any update on this. I myself am having this
same issue, where "Class 'SendGridClient' not found". All I have is the
base download of the sendgrid-php codebase and I have changed the require
statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314361038>
, or mute the thread <https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%0b
AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCg
awks5sMyZlgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314370150,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARM2r3GuvHDQNImVmbWzRUn9gwKdTQ2Wks5sMzAvgaJpZM4OL-VK
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314371168 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6mcNWlJkBFv38Nd9KucG0BGPoXYoks5sMzE6gaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6kuMy_nKbGoxy9pMi9zIDNTxtWKGks5sMzE6gaJpZM4OL-VK.gif

If I remove the getenv() around the API key I get

202Array ( [0] => HTTP/1.1 202 Accepted [1] => Server: nginx [2] => Date: Tue, 11 Jul 2017 08:37:48 GMT [3] => Content-Type: text/plain; charset=utf-8 [4] => Content-Length: 0 [5] => Connection: keep-alive [6] => X-Message-Id: s84O77EqTEKAl8LLztwx-Q [7] => X-Frame-Options: DENY [8] => Access-Control-Allow-Origin: https://sendgrid.api-docs.io [9] => Access-Control-Allow-Methods: POST [10] => Access-Control-Allow-Headers: Authorization, Content-Type, On-behalf-of, x-sg-elas-acl [11] => Access-Control-Max-Age: 600 [12] => X-No-CORS-Reason: https://sendgrid.com/docs/Classroom/Basics/API/cors.html [13] => [14] => )

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:24
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

I ran into the same issue. I think that issue with the verification is due
to how you are setting your API key. if you remove the setenv() function
and just hardcode the API key, it should work. But it is not a best
practice to hardcode API keys into your codebase.

On Tue, Jul 11, 2017 at 1:19 AM, ianh2 notifications@github.com wrote:

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification
error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I was wondering if there was any update on this. I myself am having this
same issue, where "Class 'SendGridClient' not found". All I have is the
base download of the sendgrid-php codebase and I have changed the require
statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314361038>
, or mute the thread <https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%0b
AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCg
awks5sMyZlgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314370150,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARM2r3GuvHDQNImVmbWzRUn9gwKdTQ2Wks5sMzAvgaJpZM4OL-VK
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314371168 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6mcNWlJkBFv38Nd9KucG0BGPoXYoks5sMzE6gaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6kuMy_nKbGoxy9pMi9zIDNTxtWKGks5sMzE6gaJpZM4OL-VK.gif

Awesome. Glad I could help out a little bit.

On Tue, Jul 11, 2017 at 1:39 AM, ianh2 notifications@github.com wrote:

If I remove the getenv() around the API key I get

202Array ( [0] => HTTP/1.1 202 Accepted [1] => Server: nginx [2] => Date:
Tue, 11 Jul 2017 08:37:48 GMT [3] => Content-Type: text/plain;
charset=utf-8 [4] => Content-Length: 0 [5] => Connection: keep-alive [6] =>
X-Message-Id: s84O77EqTEKAl8LLztwx-Q [7] => X-Frame-Options: DENY [8] =>
Access-Control-Allow-Origin: https://sendgrid.api-docs.io [9] =>
Access-Control-Allow-Methods: POST [10] => Access-Control-Allow-Headers:
Authorization, Content-Type, On-behalf-of, x-sg-elas-acl [11] =>
Access-Control-Max-Age: 600 [12] => X-No-CORS-Reason:
https://sendgrid.com/docs/Classroom/Basics/API/cors.html [13] => [14] => )

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:24
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I ran into the same issue. I think that issue with the verification is due
to how you are setting your API key. if you remove the setenv() function
and just hardcode the API key, it should work. But it is not a best
practice to hardcode API keys into your codebase.

On Tue, Jul 11, 2017 at 1:19 AM, ianh2 notifications@github.com wrote:

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification
error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I was wondering if there was any update on this. I myself am having this
same issue, where "Class 'SendGridClient' not found". All I have is the
base download of the sendgrid-php codebase and I have changed the require
statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#
issuecomment-314361038>
, or mute the thread <https://github.com/notifications/unsubscribe-auth/
https://github.com/notifications/unsubscribe-auth/%0b
AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCg
awks5sMyZlgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
issuecomment-314370150>,
or mute the thread
ARM2r3GuvHDQNImVmbWzRUn9gwKdTQ2Wks5sMzAvgaJpZM4OL-VK>
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314371168>
, or mute the thread AceR6mcNWlJkBFv38Nd9KucG0BGPoXYoks5sMzE6gaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6kuMy_
nKbGoxy9pMi9zIDNTxtWKGks5sMzE6gaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314374781,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARM2rxoDECaFj7SAcD9_gyfN1GtaaWNSks5sMzSpgaJpZM4OL-VK
.

Interesting. I get the error message but the mail still gets sent. I wasn't expecting that

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:41
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Awesome. Glad I could help out a little bit.

On Tue, Jul 11, 2017 at 1:39 AM, ianh2 notifications@github.com wrote:

If I remove the getenv() around the API key I get

202Array ( [0] => HTTP/1.1 202 Accepted [1] => Server: nginx [2] => Date:
Tue, 11 Jul 2017 08:37:48 GMT [3] => Content-Type: text/plain;
charset=utf-8 [4] => Content-Length: 0 [5] => Connection: keep-alive [6] =>
X-Message-Id: s84O77EqTEKAl8LLztwx-Q [7] => X-Frame-Options: DENY [8] =>
Access-Control-Allow-Origin: https://sendgrid.api-docs.io [9] =>
Access-Control-Allow-Methods: POST [10] => Access-Control-Allow-Headers:
Authorization, Content-Type, On-behalf-of, x-sg-elas-acl [11] =>
Access-Control-Max-Age: 600 [12] => X-No-CORS-Reason:
https://sendgrid.com/docs/Classroom/Basics/API/cors.html [13] => [14] => )

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:24
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I ran into the same issue. I think that issue with the verification is due
to how you are setting your API key. if you remove the setenv() function
and just hardcode the API key, it should work. But it is not a best
practice to hardcode API keys into your codebase.

On Tue, Jul 11, 2017 at 1:19 AM, ianh2 notifications@github.com wrote:

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification
error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I was wondering if there was any update on this. I myself am having this
same issue, where "Class 'SendGridClient' not found". All I have is the
base download of the sendgrid-php codebase and I have changed the require
statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#
issuecomment-314361038>
, or mute the thread <https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%0b
https://github.com/notifications/unsubscribe-auth/%0b
AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCg
awks5sMyZlgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/sendgrid/sendgrid-php/issues/412# issuecomment-314370150>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%0b
ARM2r3GuvHDQNImVmbWzRUn9gwKdTQ2Wks5sMzAvgaJpZM4OL-VK>
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314371168>
, or mute the thread <https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%0b
AceR6mcNWlJkBFv38Nd9KucG0BGPoXYoks5sMzE6gaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6kuMy_
nKbGoxy9pMi9zIDNTxtWKGks5sMzE6gaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314374781,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARM2rxoDECaFj7SAcD9_gyfN1GtaaWNSks5sMzSpgaJpZM4OL-VK
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314375239 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6kXIpEWxhPBBX9gv-FiXNp74LqIZks5sMzUQgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6tNQEbMwweSApjZV_uVih3r1kuCtks5sMzUQgaJpZM4OL-VK.gif

I dont believe it is an error message. That is just a response that the API
sends back. Yours looks like it was a success and accepted. if you remove
or comment out the following lines, you should not get any response other
than your email being sent:

echo $response->statusCode();
print_r($response->headers());
echo $response->body();

On Tue, Jul 11, 2017 at 1:57 AM, ianh2 notifications@github.com wrote:

Interesting. I get the error message but the mail still gets sent. I
wasn't expecting that

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:41

To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

Awesome. Glad I could help out a little bit.

On Tue, Jul 11, 2017 at 1:39 AM, ianh2 notifications@github.com wrote:

If I remove the getenv() around the API key I get

202Array ( [0] => HTTP/1.1 202 Accepted [1] => Server: nginx [2] => Date:
Tue, 11 Jul 2017 08:37:48 GMT [3] => Content-Type: text/plain;
charset=utf-8 [4] => Content-Length: 0 [5] => Connection: keep-alive [6]
=>
X-Message-Id: s84O77EqTEKAl8LLztwx-Q [7] => X-Frame-Options: DENY [8] =>
Access-Control-Allow-Origin: https://sendgrid.api-docs.io [9] =>
Access-Control-Allow-Methods: POST [10] => Access-Control-Allow-Headers:
Authorization, Content-Type, On-behalf-of, x-sg-elas-acl [11] =>
Access-Control-Max-Age: 600 [12] => X-No-CORS-Reason:
https://sendgrid.com/docs/Classroom/Basics/API/cors.html [13] => [14]
=> )

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:24
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I ran into the same issue. I think that issue with the verification is
due
to how you are setting your API key. if you remove the setenv() function
and just hardcode the API key, it should work. But it is not a best
practice to hardcode API keys into your codebase.

On Tue, Jul 11, 2017 at 1:19 AM, ianh2 notifications@github.com wrote:

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification
error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to
V3
(#412)

I was wondering if there was any update on this. I myself am having
this
same issue, where "Class 'SendGridClient' not found". All I have is
the
base download of the sendgrid-php codebase and I have changed the
require
statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#
issuecomment-314361038>
, or mute the thread <https://github.com/notifications/unsubscribe-
auth/ https://github.com/notifications/unsubscribe-auth/%0b
https://github.com/notifications/unsubscribe-auth/%0b
AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCg
awks5sMyZlgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/sendgrid/sendgrid-php/issues/412# <
https://github.com/sendgrid/sendgrid-php/issues/412# >
issuecomment-314370150>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ <
https://github.com/notifications/unsubscribe-auth/%0b>
ARM2r3GuvHDQNImVmbWzRUn9gwKdTQ2Wks5sMzAvgaJpZM4OL-VK>
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#
issuecomment-314371168>
, or mute the thread <https://github.com/notifications/unsubscribe-auth/
https://github.com/notifications/unsubscribe-auth/%0b
AceR6mcNWlJkBFv38Nd9KucG0BGPoXYoks5sMzE6gaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6kuMy_
nKbGoxy9pMi9zIDNTxtWKGks5sMzE6gaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
issuecomment-314374781>,
or mute the thread
gyfN1GtaaWNSks5sMzSpgaJpZM4OL-VK>
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314375239>
, or mute the thread auth/AceR6kXIpEWxhPBBX9gv-FiXNp74LqIZks5sMzUQgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6tNQEbMwweSApjZV_
uVih3r1kuCtks5sMzUQgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314379331,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARM2r6wa7NpeV9RS9gBHk4OjSJR7W-t5ks5sMzjtgaJpZM4OL-VK
.

Yes, sorry I was a bit slow there!

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:59
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

I dont believe it is an error message. That is just a response that the API
sends back. Yours looks like it was a success and accepted. if you remove
or comment out the following lines, you should not get any response other
than your email being sent:

echo $response->statusCode();
print_r($response->headers());
echo $response->body();

On Tue, Jul 11, 2017 at 1:57 AM, ianh2 notifications@github.com wrote:

Interesting. I get the error message but the mail still gets sent. I
wasn't expecting that

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:41

To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

Awesome. Glad I could help out a little bit.

On Tue, Jul 11, 2017 at 1:39 AM, ianh2 notifications@github.com wrote:

If I remove the getenv() around the API key I get

202Array ( [0] => HTTP/1.1 202 Accepted [1] => Server: nginx [2] => Date:
Tue, 11 Jul 2017 08:37:48 GMT [3] => Content-Type: text/plain;
charset=utf-8 [4] => Content-Length: 0 [5] => Connection: keep-alive [6]
=>
X-Message-Id: s84O77EqTEKAl8LLztwx-Q [7] => X-Frame-Options: DENY [8] =>
Access-Control-Allow-Origin: https://sendgrid.api-docs.io [9] =>
Access-Control-Allow-Methods: POST [10] => Access-Control-Allow-Headers:
Authorization, Content-Type, On-behalf-of, x-sg-elas-acl [11] =>
Access-Control-Max-Age: 600 [12] => X-No-CORS-Reason:
https://sendgrid.com/docs/Classroom/Basics/API/cors.html [13] => [14]
=> )

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:24
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I ran into the same issue. I think that issue with the verification is
due
to how you are setting your API key. if you remove the setenv() function
and just hardcode the API key, it should work. But it is not a best
practice to hardcode API keys into your codebase.

On Tue, Jul 11, 2017 at 1:19 AM, ianh2 notifications@github.com wrote:

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification
error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to
V3
(#412)

I was wondering if there was any update on this. I myself am having
this
same issue, where "Class 'SendGridClient' not found". All I have is
the
base download of the sendgrid-php codebase and I have changed the
require
statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#
issuecomment-314361038>
, or mute the thread <https://github.com/notifications/unsubscribe- https://github.com/notifications/unsubscribe-%0b
auth/ https://github.com/notifications/unsubscribe-auth/%0b
https://github.com/notifications/unsubscribe-auth/%0b
AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCg
awks5sMyZlgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/sendgrid/sendgrid-php/issues/412# <https://github.com/sendgrid/sendgrid-php/issues/412# < > <
https://github.com/sendgrid/sendgrid-php/issues/412# >
issuecomment-314370150>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%20%3c%0b <
https://github.com/notifications/unsubscribe-auth/%0b>
ARM2r3GuvHDQNImVmbWzRUn9gwKdTQ2Wks5sMzAvgaJpZM4OL-VK>
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#
issuecomment-314371168>
, or mute the thread <https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%0b
https://github.com/notifications/unsubscribe-auth/%0b
AceR6mcNWlJkBFv38Nd9KucG0BGPoXYoks5sMzE6gaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6kuMy_
nKbGoxy9pMi9zIDNTxtWKGks5sMzE6gaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/sendgrid/sendgrid-php/issues/412# issuecomment-314374781>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ARM2rxoDECaFj7SAcD9_ https://github.com/notifications/unsubscribe-auth/ARM2rxoDECaFj7SAcD9_%0b
gyfN1GtaaWNSks5sMzSpgaJpZM4OL-VK>
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314375239>
, or mute the thread <https://github.com/notifications/unsubscribe- https://github.com/notifications/unsubscribe-%0b
auth/AceR6kXIpEWxhPBBX9gv-FiXNp74LqIZks5sMzUQgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6tNQEbMwweSApjZV_
uVih3r1kuCtks5sMzUQgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314379331,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARM2r6wa7NpeV9RS9gBHk4OjSJR7W-t5ks5sMzjtgaJpZM4OL-VK
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314379881 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6im8l89CBN8J6NP5M0fc1m5JSyb0ks5sMzlsgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6m-xKCnxhWRzQwg6w7ATvvqA9LiNks5sMzlsgaJpZM4OL-VK.gif

What I've done to get it to work is

  1. I have a folder at the same level as public_html where I store my database connection data

  2. I created a new file in there that declares a $APIKey variable

  3. I included a require path to the folder and file

  4. I removed the getenv() code

  5. This works

I do get an additional "=" character at the end of the email which I also get with the V2 API. This is foxing me as I can't see where it comes from

The good thing is that I'm accessing the API via this

require ($topublic."sendgrid-php3/sendgrid-php.php");

This appears to allow me to have both APIs (V2 and V3) co existing and will allow me to migrate my code gracefully

What I need now is for Elmer to tell us how to include an attachment using the library

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:59
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

I dont believe it is an error message. That is just a response that the API
sends back. Yours looks like it was a success and accepted. if you remove
or comment out the following lines, you should not get any response other
than your email being sent:

echo $response->statusCode();
print_r($response->headers());
echo $response->body();

On Tue, Jul 11, 2017 at 1:57 AM, ianh2 notifications@github.com wrote:

Interesting. I get the error message but the mail still gets sent. I
wasn't expecting that

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:41

To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

Awesome. Glad I could help out a little bit.

On Tue, Jul 11, 2017 at 1:39 AM, ianh2 notifications@github.com wrote:

If I remove the getenv() around the API key I get

202Array ( [0] => HTTP/1.1 202 Accepted [1] => Server: nginx [2] => Date:
Tue, 11 Jul 2017 08:37:48 GMT [3] => Content-Type: text/plain;
charset=utf-8 [4] => Content-Length: 0 [5] => Connection: keep-alive [6]
=>
X-Message-Id: s84O77EqTEKAl8LLztwx-Q [7] => X-Frame-Options: DENY [8] =>
Access-Control-Allow-Origin: https://sendgrid.api-docs.io [9] =>
Access-Control-Allow-Methods: POST [10] => Access-Control-Allow-Headers:
Authorization, Content-Type, On-behalf-of, x-sg-elas-acl [11] =>
Access-Control-Max-Age: 600 [12] => X-No-CORS-Reason:
https://sendgrid.com/docs/Classroom/Basics/API/cors.html [13] => [14]
=> )

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 09:24
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3
(#412)

I ran into the same issue. I think that issue with the verification is
due
to how you are setting your API key. if you remove the setenv() function
and just hardcode the API key, it should work. But it is not a best
practice to hardcode API keys into your codebase.

On Tue, Jul 11, 2017 at 1:19 AM, ianh2 notifications@github.com wrote:

Hi Barney

Yes Elmer seems to have fixed it although I am getting a verification
error that seems to be associated with the API key

Ian

From: Barneybarker [mailto:[email protected]]
Sent: 11 July 2017 08:38
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to
V3
(#412)

I was wondering if there was any update on this. I myself am having
this
same issue, where "Class 'SendGridClient' not found". All I have is
the
base download of the sendgrid-php codebase and I have changed the
require
statement to: require("sendgrid-php/lib/loader.php");.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#
issuecomment-314361038>
, or mute the thread <https://github.com/notifications/unsubscribe- https://github.com/notifications/unsubscribe-%0b
auth/ https://github.com/notifications/unsubscribe-auth/%0b
https://github.com/notifications/unsubscribe-auth/%0b
AceR6tNUHBHc3Uv3IOPQXxfumW8x8xdFks5sMyZlgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6rlh9wZZhQdfOkiw8rHz0tCfCg
awks5sMyZlgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/sendgrid/sendgrid-php/issues/412# <https://github.com/sendgrid/sendgrid-php/issues/412# < > <
https://github.com/sendgrid/sendgrid-php/issues/412# >
issuecomment-314370150>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%20%3c%0b <
https://github.com/notifications/unsubscribe-auth/%0b>
ARM2r3GuvHDQNImVmbWzRUn9gwKdTQ2Wks5sMzAvgaJpZM4OL-VK>
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#
issuecomment-314371168>
, or mute the thread <https://github.com/notifications/unsubscribe-auth/ https://github.com/notifications/unsubscribe-auth/%0b
https://github.com/notifications/unsubscribe-auth/%0b
AceR6mcNWlJkBFv38Nd9KucG0BGPoXYoks5sMzE6gaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6kuMy_
nKbGoxy9pMi9zIDNTxtWKGks5sMzE6gaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/sendgrid/sendgrid-php/issues/412# issuecomment-314374781>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ARM2rxoDECaFj7SAcD9_ https://github.com/notifications/unsubscribe-auth/ARM2rxoDECaFj7SAcD9_%0b
gyfN1GtaaWNSks5sMzSpgaJpZM4OL-VK>
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314375239>
, or mute the thread <https://github.com/notifications/unsubscribe- https://github.com/notifications/unsubscribe-%0b
auth/AceR6kXIpEWxhPBBX9gv-FiXNp74LqIZks5sMzUQgaJpZM4OL-VK> . <
https://github.com/notifications/beacon/AceR6tNQEbMwweSApjZV_
uVih3r1kuCtks5sMzUQgaJpZM4OL-VK.gif>

β€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314379331,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARM2r6wa7NpeV9RS9gBHk4OjSJR7W-t5ks5sMzjtgaJpZM4OL-VK
.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314379881 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6im8l89CBN8J6NP5M0fc1m5JSyb0ks5sMzlsgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6m-xKCnxhWRzQwg6w7ATvvqA9LiNks5sMzlsgaJpZM4OL-VK.gif

Has this been solved yet or any clear instructions? This is pretty crazy just to be able to use the API, and can't believe it is this screwed up and it is out linked on SendGrid's documentation to use this.
I had all of these problems skimming through fiddling for a few hours to try and make it work.

Can anyone just link an old working version with simple instructions? Edit: I think I found V2, just need old documentation.

Hi Joe

I think it's been solved but there aren't clear instructions. The example is incorrect and we need guidance on how to access the API key as the example will give an error

I think it's disappointed that there aren't 1) Clear, workable examples & 2) A migration path from V2 to V3

Ian

From: JoeD101 [mailto:[email protected]]
Sent: 11 July 2017 12:44
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Has this been solved yet or any clear instructions? This is pretty crazy just to be able to use the API - I had all of these problems skimming through fiddling for a few hours to try and make it work.

If anything, please just link me to a working version with simple instructions.

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314418263 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6rHsWVJ9KPzAAnd82JJvtyYtvkwvks5sM2AUgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6kLbilWybGb0oSKdW7HHe1xP6ti2ks5sM2AUgaJpZM4OL-VK.gif

Hello @JoeD101,

My apologies. I have a build script that is broken which I will be repairing so that those not using composer won't have to go through all this trouble.

Please use these files: sendgrid-php.zip and the documentation included in this repo.

If you continue to have trouble with the file I've included, please reach back out.

This library is about to be upgraded shortly and I will keep the comments in this thread as reference to help ease usage. Thank you so much for the valuable feedback!

With Best Regards,

Elmer

@thinkingserious Thank you for your response. I got that package to work just fine with V3 API code for sending emails.

Sweet, thanks for the follow up!

Things that need to be documented

  1. Sending an e-mail to more than one person

Repeating $to seems to work

$to = new SendGridEmail(null, "[email protected] test@example.com ");

$to = new SendGridEmail(null, "[email protected] test@example.com ");

  1. Adding a cc

Adding $cc doesn't seem to work (either that or the second "to" didn't work)

$cc = new SendGridEmail(null, " test@example.com [email protected]");

  1. How do you add an attachment?

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 12 July 2017 02:57
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Sweet, thanks for the follow up!

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314622227 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6ioss7Yrw5QYY64QdGbrVDwGfK5bks5sNCfrgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6hXv5XYtygRUw93Wux4M8e9gIT-Kks5sNCfrgaJpZM4OL-VK.gif

Hi @ianh2,

Thanks again for taking the time to give us some feedback!

  1. Here is a complete example that you can use to execute various use cases, including the ones you mentioned.

  2. Please take a look at our upcoming refactor here and let me know what you think. Thanks!

With Best Regards,

Elmer

Hi Elmer

The method of multiple addressees seems clumsy compared with the V2 interface. I wondering how to do it if I have a variable number of addresses. Could I use an array?

The puzzler is this line

$attachment->setContent("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12");

Is this fixed (I hope so!)?

On the refactor page, if you are dealing with idiots like me who blindly copy the code, the line

$apiKey = getenv('SENDGRID_API_KEY');

Will not work and will give an authentication error.

The below is good and answers my first question

$tos = [
new SendGridMailEmail("[email protected]", "Example User1"),
new SendGridMailEmail("[email protected]", "Example User2"),
new SendGridMailEmail("[email protected]", "Example User3")
];

Much better examples!

I've got a major paragliding competition this weekend in Grasmere so can't do much more until next week

Thanks for your help

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 12 July 2017 20:22
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Hi @ianh2 https://github.com/ianh2 ,

Thanks again for taking the time to give us some feedback!

  1. Here is a complete example https://github.com/sendgrid/sendgrid-php/blob/master/examples/helpers/mail/example.php that you can use to execute various use cases, including the ones you mentioned.

  2. Please take a look at our upcoming refactor here https://github.com/sendgrid/sendgrid-php/issues/413 and let me know what you think. Thanks!

With Best Regards,

Elmer

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-314870822 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6tpET4jUUzROWJ-vB-Jyz0SXE4A-ks5sNRzzgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6sDkeHx_tyrO99CsQ6otjWarJHuIks5sNRzzgaJpZM4OL-VK.gif

Hi @ianh2,

Great feedback once again!

Good luck and have fun with the paragliding competition, that sounds amazing!

Unfortunately, we don't have an addTos() function to accept an array today, but this is coming with the new version.

This line $apiKey = getenv('SENDGRID_API_KEY'); is key for us, since we are trying to keep people from putting their keys in their source code. I'll make sure to clarify this.

With Best Regards,

Elmer

Elmer

I've used your example "function helloEmail()" as set out in the example. It runs without errors but no mail get sent.

I have to say that I am very bemused by this upgrade. The SendGrid web site says "SendGrid provides libraries to help you quickly and easily integrate with the v3 Web API". With V2 you had a simple and straightforward interface. With V3 you seem to have gone out of your way to make it more complex and less easy to implement. I'm not certain what library I'm supposed to using and it does look like you're writing a completely new one. There doesn't seem to have been much thought on updating from V2 to V3 and easing that transition.

I think the best way forward is for me to stick to V2 and wait for something stable to emerge.

The V3 is real step backwards; just consider sending an attachment

V2
$email->setAttachment($uploadfile);

V3

$attachment2 = new Attachment();
$attachment2->setContent("BwdW");
$attachment2->setType("image/png");
$attachment2->setFilename("banner.png");
$attachment2->setDisposition("inline");
$attachment2->setContentId("Banner");
$mail->addAttachment($attachment2);

7 lines of code instead of 1!

Hello @ianh2,

What was the error message? Also, I'd be happy to look at your request object to help debug. Just drop in this line of code before you send the email: echo json_encode($mail, JSON_PRETTY_PRINT), "\n";

The new helper will allow you to do this:

$msg->addAttachment("balance_001.pdf",
                    "base64 encoded content",
                    "application/pdf",
                    "attachment",
                    "Balance Sheet");

As for the step backward, this is true. The PHP SDK that supported v2 was well done, but it was tightly coupled to the v2 mail/send endpoint, as was our other 6 SDKs. So we took a step back to refactor that coupling (and removing third party dependencies while the hood was up, in this SDKs case, it was Guzzle) and allow for support of all of our 233 endpoints.

The final step of this project, which has unfortunately taken far too long, is reflected in this issue. Given your PHP expertise and usage of SendGrid, your feedback would be tremendous. Please do take a look when you get a chance. We want to release those helpers ASAP.

With Best Regards,

Elmer

Hi Elmer

I think I said in the e-mail that I didn't get any errors but didn't get an e-mail either

Ian

From: Elmer Thomas [mailto:[email protected]]
Sent: 19 July 2017 20:12
To: sendgrid/sendgrid-php
Cc: ianh2; Mention
Subject: Re: [sendgrid/sendgrid-php] Updating from SendGrid V2 API to V3 (#412)

Hello @ianh2 https://github.com/ianh2 ,

What was the error message https://github.com/sendgrid/sendgrid-php/blob/master/TROUBLESHOOTING.md#error-messages ? Also, I'd be happy to look at your request object to help debug. Just drop in this line of code before you send the email: echo json_encode($mail, JSON_PRETTY_PRINT), "n";

The new helper will allow you to do this:

$msg->addAttachment("balance_001.pdf",
"base64 encoded content",
"application/pdf",
"attachment",
"Balance Sheet");

As for the step backward, this is true. The PHP SDK that supported v2 was well done, but it was tightly coupled to the v2 mail/send endpoint, as was our other 6 SDKs. So we took a step back to refactor that coupling (and removing third party dependencies while the hood was up, in this SDKs case, it was Guzzle) and allow for support of all of our 233 endpoints https://sendgrid.com/blog/stoplight-io-to-test-api-endpoints/ .

The final step of this project, which has unfortunately taken far too long, is reflected in this issue https://github.com/sendgrid/sendgrid-php/issues/413 . Given your PHP expertise and usage of SendGrid, your feedback would be tremendous. Please do take a look when you get a chance. We want to release those helpers ASAP.

With Best Regards,

Elmer

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/sendgrid/sendgrid-php/issues/412#issuecomment-316487627 , or mute the thread https://github.com/notifications/unsubscribe-auth/AceR6senSDKTfnABmb4lvAWond9sdDPBks5sPlUQgaJpZM4OL-VK . https://github.com/notifications/beacon/AceR6kh9uIaGg0Qi8yscRvzIGCN4AVaVks5sPlUQgaJpZM4OL-VK.gif

HI @ianh2,

If you do this, you should be able to grab the error message.

Hi Elmer

That’s not the same code that you use in your example

The example says

$response = $sg->client->mail()->send()->post($request_body);

Your link says

$response = $sendgrid->client->mail()->send()->post($mail);

If I use the latter I get

[Wed Jul 19 20:53:18 2017] [error] [client 82.69.11.147:35200] AH01215: PHP Fatal error:  Call to a member function mail() on a non-object in /home/sites/...../public_html/testarea/CSC_TestMail.php on line 112: /home/sites/.../public_html/testarea/CSC_TestMail.php

And the page does not complete

If I use the former then the page completes to the footer. I get no error message and no emails

Signing off until tomorrow

Ian

@ianh2,

Please ping me when you start working on this again tomorrow so I can try to help you in real time.

If you start before me, can you tell me these values after you send the email:

echo $response->statusCode();
print_r($response->headers());
echo $response->body();

401Array ( [0] => HTTP/1.1 401 Unauthorized [1] => Server: nginx [2] => Date: Thu, 20 Jul 2017 11:41:49 GMT [3] => Content-Type: application/json [4] => Content-Length: 88 [5] => Connection: keep-alive [6] => X-Frame-Options: DENY [7] => Access-Control-Allow-Origin: https://sendgrid.api-docs.io [8] => Access-Control-Allow-Methods: POST [9] => Access-Control-Allow-Headers: Authorization, Content-Type, On-behalf-of, x-sg-elas-acl [10] => Access-Control-Max-Age: 600 [11] => X-No-CORS-Reason: https://sendgrid.com/docs/Classroom/Basics/API/cors.html [12] => [13] => ) {"errors":[{"message":"Permission denied, wrong credentials","field":null,"help":null}]}

Puzzling because I've got the APIKey as a system variable and this worked before

What happens when you set the APIKey directly, like so? https://github.com/sendgrid/sendgrid-php/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key

If I enter the API key directly, then I get 2 e-mails. However both are to the same person. It looks like the address in the addto is ignored

Ian

Right before you make the post, could you tell me the value of:

echo json_encode($mail, JSON_PRETTY_PRINT), "\n";

Sending it to your personal e-mail
Ian

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bjornmann picture bjornmann  Β·  3Comments

moontrv picture moontrv  Β·  3Comments

Theolodewijk picture Theolodewijk  Β·  4Comments

atsareva picture atsareva  Β·  4Comments

jverlee picture jverlee  Β·  4Comments