1. Go to this page and download the library: Download sprintcube/cakephp-sendgrid library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sprintcube / cakephp-sendgrid example snippets
Plugin::load('SendGrid');
'EmailTransport' => [
...
'sendgrid' => [
'className' => 'SendGrid.SendGrid',
'apiKey' => 'your-api-key' // your api key
]
]
$email = new SendGridMailer();
$email->setTo('[email protected]')
->setTemplate('d-xxxxxx')
->deliver();
$email = new SendGridMailer();
$email->setTo('[email protected]')
->setSendAt(1649500630)
->deliver();
'sendgridWebhook' => [
'tableClass' => 'EmailQueue', // The table name that stores email data
'uniqueIdField' => 'status_id', // The field name that stores the unique message ID VARCHAR(100)
'statusField' => 'status', // The field name that stores the status of the email status VARCHAR(100)
'statusMessageField' => 'status_message', // The field name that stores the status messages TEXT
'debug' => 'true', // write incoming requests to debug log
'secure' => 'true', // enable SendGrid signed webhook security. You should enable this in production
'verification_key' => '<YOUR VERIFICATION KEY>', // The verification key from SendGrid
],
$csrf = new CsrfProtectionMiddleware();
$csrf->skipCheckCallback(function ($request) {
// Skip token check for API URLs.
if ($request->getParam('controller') === 'Webhooks') {
return true;
}
});
// Ensure routing middleware is added to the queue before CSRF protection middleware.
$middlewareQueue->add($csrf);
return $middlewareQueue;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.