PHP code example of toastnz / sendgrid-mailer

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

    

toastnz / sendgrid-mailer example snippets


$email = new SilverStripe\Control\Email\Email();
$email->setFrom('[email protected]', 'John Doe');
$email->setTo('[email protected]', 'Jane Doe');
$email->setSubject('This is a test email');
$email->setBody('Hello there, this was sent using SendGrid');
$email->addAttachment('path/to/file.pdf', 'document.pdf');
$email->send();