PHP code example of vulcandigital / silverstripe-sendgrid
1. Go to this page and download the library: Download vulcandigital/silverstripe-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/ */
vulcandigital / silverstripe-sendgrid example snippets
$sendGrid = \Vulcan\SendGrid\SendGrid::create();
$sendGrid->setSubject("We have a sale for you!");
$sendGrid->setFrom('[email protected]');
$sendGrid->setFromName('My Site');
$sendGrid->setReplyTo('[email protected]');
$sendGrid->addRecipient('[email protected]', 'Reece Alexander', [
':salutation' => 'Mr',
':button_link' => 'https://example.com/store/offer?id=aASdGdjnklashewjk12321hjkasd213'
]);
$sendGrid->setBody("<p>We thought you'd like this awesome t-shirt!</p>");
$sendGrid->setTemplateId('your-template-id');
$sendGrid->addAttachment(Image::get()->first());
$sendGrid->send();