q-alliance / qsendgridbundle
该包最新版本(1.0.4)没有可用的许可证信息。
QSendgrid邮件服务器的Symfony组件实现
1.0.4
2020-07-25 11:41 UTC
Requires
- q-alliance/qsendgrid: ^1.0
This package is not auto-updated.
Last update: 2021-10-02 17:32:38 UTC
README
Symfony组件实现QSendgrid邮件服务。
先决条件
您需要提供以下内容
- Sendgrid API密钥,可以在 Sendgrid用户界面 中创建
- 无回复电子邮件地址
密钥示例: SG.QDzWlz_gShWMVi8svP...
安装
使用composer安装QSendgridBundle
composer require q-alliance/qsendgridbundle
设置
更新 AppKernel.php
$bundles = [
...
new QAlliance\QSendgridBundle\QAllianceQSendgridBundle(),
];
更新 config.yml
# QSendgrid Configuration
q_alliance_q_sendgrid:
no_reply_email: NO_REPLY_EMAIL
sendgrid_api_key: SENDGRID_API_KEY
基本用法
从控制器获取QSendgrid邮件服务并发送简单邮件
$qs = $this->get('qalliance.qsendgrid'); $result = $qs->send('to@example.com', 'My Subject', '<h1>This is a QSendgrid test email.</h1>');
发送带附件的HTML邮件
$attachmentUrls = [ './assets/attachments/sample1.jpg', './assets/attachments/sample2.jpg' ]; $qs = $this->get('qalliance.qsendgrid'); $result = $qs->send('to@example.com', 'My Subject', '<h1>This is a QSendgrid test email with attachments.</h1>', $attachmentUrls);
将fromName作为最后一个参数(可选)
$qs = $this->get('qalliance.qsendgrid'); $result = $qs->send('to@example.com', 'My Subject', '<h1>This is a QSendgrid test email.</h1>', null, 'From Name');
发送带HTML和纯文本内容的邮件
$qs = $this->get('qalliance.qsendgrid'); $result = $qs->sendWithTextPlain('to@example.com', 'My Subject', '<h1>This is a QSendgrid test email with plain text.</h1>', 'This is a QSendgrid test email with plain text', null, 'From Name');
作者
- Vicko Franic - Github