PHP code example of jorisvaesen / cakephp-sendgrid

1. Go to this page and download the library: Download jorisvaesen/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/ */

    

jorisvaesen / cakephp-sendgrid example snippets


'EmailTransport' => [
        ...
        'sendgrid' => [
            'className' => '\JorisVaesen\Sendgrid\Mailer\Transport\SendgridTransport',
            'password' => 'your_sendgrid_api_key',
        ],
        ...
    ],

'EmailTransport' => [
        ...
        'sendgrid' => [
            'className' => '\JorisVaesen\Sendgrid\Mailer\Transport\SendgridTransport',
            'password' => 'your_sendgrid_api_key',
            'callback' => function (\SendGrid\Mail\Mail $sendgridEmail, \Cake\Mailer\Email $cakephpEmail) {
                if ($cakephpEmail->getSubject() === 'If you open this mail...') {
                    $sendgridEmail->setOpenTracking(true);
                }
                
                return $sendgridEmail;
            },
        ],
        ...
    ],