kardasz / swiftmailer-transport-sendgrid
SwiftMailer Sendgrid Transport
Installs: 23 972
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 4
Open Issues: 0
Requires
- php: >=7.2.0
- sendgrid/sendgrid: ~7
- swiftmailer/swiftmailer: ^6.0
Requires (Dev)
- mockery/mockery: ^1.1
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-11-07 18:38:19 UTC
README
Installation
composer require kardasz/swiftmailer-transport-sendgrid
Usage
use Kardasz\Swiftmailer\Transport\SendGridTransport; use SendGrid; use Swift_Events_SimpleEventDispatcher; use Swift_Mailer; use Swift_Message; require 'vendor/autoload.php'; // SendGrid API KEY $apiKey = getenv('SENDGRID_API_KEY'); // SendGrid Client $sendgrid = new SendGrid($apiKey); // SendGrid Transport $transport = new SendGridTransport($sendgrid); // Create the Mailer using your created Transport $mailer = new Swift_Mailer($transport); // Create a message $message = (new Swift_Message('Wonderful Subject')) ->setFrom(['john@doe.com' => 'John Doe']) ->setTo(['receiver@domain.org', 'other@domain.org' => 'A name']) ->setBody('Here is the message itself') ; // Send the message $result = $mailer->send($message);