toastnz / sendgrid-mailer
silverstripe 的 SendGrid 邮件发送器
4.0.3
2021-04-30 08:42 UTC
Requires
This package is auto-updated.
Last update: 2024-08-29 05:24:30 UTC
README
使用 SendGrid API 发送电子邮件的简单邮件发送器模块。
需求
- silverstripe/cms ^4.3.x
- silverstripe/framework ^4.3.x
- sendgrid/sendgrid ^7.3
安装
composer require toastnz/sendgrid-mailer
配置
将以下内容添加到您的 app.yml
Toast\SSSendGrid\SendGridMailer: api_key: 'YOUR_SENDGRID_API_KEY'
使用方法
简单地使用 SilverStripe 框架提供的 Email 类。
$email = new SilverStripe\Control\Email\Email(); $email->setFrom('from@example.com', 'John Doe'); $email->setTo('to@example.com', '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();