卡达斯 / swiftmailer-transport-sendgrid
SwiftMailer Sendgrid 传输
1.0.2
2019-10-04 07:42 UTC
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-09-07 18:24:32 UTC
README
安装
composer require kardasz/swiftmailer-transport-sendgrid
使用方法
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);