Download the PHP package godpod/sendgrid without Composer
On this page you can find all versions of the php package godpod/sendgrid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sendgrid
SendGrid-php
This library allows you to quickly and easily send emails through SendGrid using PHP.
WARNING: This module was recently upgraded from 1.1.7 to 2.X. There were API breaking changes for various method names. See usage for up to date method names.
Important: This library requires PHP 5.3 or higher.
Installation
Add SendGrid to your composer.json
file. If you are not using Composer, you should be. It's an excellent way to manage dependencies in your PHP application.
Then at the top of your PHP script require the autoloader:
Alternative: Install from zip
If you are not using Composer, simply download and install the latest packaged release of the library as a zip.
⬇︎ Download Packaged Library ⬇︎
Then require the library from package:
Previous versions of the library can be found in the version index.
Example App
There is a sendgrid-php-example app to help jumpstart your development.
Usage
To begin using this library, initialize the SendGrid object with your SendGrid credentials.
Create a new SendGrid Email object and add your message details.
Send it.
addTo
You can add one or multiple TO addresses using addTo
.
setTos
If you prefer, you can add multiple TO addresses as an array using the setTos
method. This will unset any previous addTo
s you appended.
setFrom
setFromName
setReplyTo
Cc
addCc
setCc
setCcs
removeCc
Bcc
Use multiple addTo
s as a superior alternative to setBcc
.
But if you do still have a need for Bcc you can do the following:
addBcc
setBcc
setBccs
removeBcc
setSubject
setText
setHtml
setDate
setSendAt
setSendEachAt
addSendEachAt
Categories
Categories are used to group email statistics provided by SendGrid.
To use a category, simply set the category name. Note: there is a maximum of 10 categories per email.
addCategory
setCategory
setCategories
removeCategory
Attachments
Attachments are currently file based only, with future plans for an in memory implementation as well.
File attachments are limited to 7 MB per file.
addAttachment
setAttachment
setAttachments
removeAttachment
You can tag files for use as inline HTML content. It will mark the file for inline disposition using the specified "cid".
Important Gotcha: setBcc
is not supported with attachments. This is by design. Instead use multiple addTo
s. Each user will receive their own personalized email with that setup, and only see their own email.
Standard setBcc
will hide who the email is addressed to. If you use the multiple addTo, each user will receive a personalized email showing *only their email. This is more friendly and more personal. Additionally, it is a good idea to use multiple addTo
s because setBcc is not supported with attachments. This is by design.
So just remember, when thinking 'bcc', instead use multiple addTo
s.
Substitutions
Substitutions can be used to customize multi-recipient emails, and tailor them for the user
addSubstitution
Substitutions can also be used to customize multi-recipient subjects.
setSubstitutions
Sections
Sections can be used to further customize messages for the end users. A section is only useful in conjunction with a substitution value.
addSection
setSections
Unique Arguments
Unique Arguments are used for tracking purposes
addUniqueArg / addUniqueArgument
setUniqueArgs / setUniqueArguments
Filter Settings
Filter Settings are used to enable and disable apps, and to pass parameters to those apps.
addFilter / addFilterSetting
setFilters / setFilterSettings
Headers
You can add standard email message headers as necessary.
addHeader
setHeaders
removeHeader
Options
Options may be passed to the library when initializing the SendGrid object:
Changing URL
You may change the URL sendgrid-php uses to send email by supplying various parameters to options
, all parameters are optional:
A full URL may also be provided:
Ignoring SSL certificate verification
You can optionally ignore verification of SSL certificate when using the Web API.
Sending to 1,000s of emails in one batch
Sometimes you might want to send 1,000s of emails in one request. You can do that. It is recommended you break each batch up in 1,000 increments. So if you need to send to 5,000 emails, then you'd break this into a loop of 1,000 emails at a time.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Running Tests
The existing tests in the test
directory can be run using PHPUnit with the following command:
or if you already have PHPUnit installed globally.
Releasing
To release a new version of this library, update the version in all locations, tag the version, and then push the tag up. Packagist.org takes care of the rest.
Testing uploading to Amazon S3
If you want to test uploading the zipped file to Amazon S3 (SendGrid employees only), do the following.