PHP code example of napoleon / omnismtp-sendgrid

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

    

napoleon / omnismtp-sendgrid example snippets




$key = 'api-key';

$sendgrid = \OmniSmtp\OmniSmtp::create(\Napoleon\OmniSmtp\SendGrid::class, $key);

$sendgrid->setSubject('The Mail Subject')
    ->setFrom('[email protected]')
    ->setRecipients('[email protected]')
    ->setContent('<p>Hello From SendGrid OmniMail</p>')
    ->send();



$key = 'api-key';

$sendgrid = \OmniSmtp\OmniSmtp::create(\Napoleon\OmniSmtp\SendGrid::class, $key);

$sendgrid->setSubject('The Mail Subject')
    ->setFrom('[email protected]')
    ->setRecipients('[email protected]', '[email protected]')
    ->setContent('<p>Hello From SendGrid OmniMail</p>')
    ->send();