Simple to use mailer, built with Sendgrid in the background. Sends basic html email, with or without email attachments.
You will need to provide:
- Sendgrid API key, which can be created in Sendgrid user interface
- No Reply email address
Key example: SG.QDzWlz_gShWMVi8svP...
Install QSendgrid with composer:
composer require q-alliance/qsendgrid
<?php
use QAlliance\QSendgrid;
// Create new QSendgrid object
$qs = new QSendgrid('NO_REPLY_EMAIL', 'SENDGRID_API_KEY');
// Send email to given address with given subject and content, returns bool
$result = $qs->send('to@example.com', 'My Subject', '<h1>This is a QSendgrid test email.</h1>');
<?php
use QAlliance\QSendgrid;
$attachmentUrls = [
'./src/attachments/sample1.jpg',
'./src/attachments/sample2.jpg'
];
// Create new QSendgrid object
$qs = new QSendgrid('NO_REPLY_EMAIL', 'SENDGRID_API_KEY');
// Send email to given address with given subject and content, returns bool
$result = $qs->send('to@example.com', 'My Subject', '<h1>This is a QSendgrid test email with attachments.</h1>', $attachmentUrls);
Edit PHPUnit bootstrap file (phpunit.bootstrap.php) and add required values. Run tests with this command:
vendor/bin/phpunit --bootstrap phpunit.bootstrap.php
- Vicko Franic - Initial work - Github