tparcina / qsendgridbundle
此包最新版本(1.1.1)没有可用的许可证信息。
QSsendgrid 邮件服务器的 Symfony 包实现
1.1.1
2021-09-16 14:11 UTC
Requires
- tparcina/qsendgrid: ^1.0
This package is not auto-updated.
Last update: 2024-09-28 05:48:47 UTC
README
Symfony 包实现 QSsendgrid 邮件服务
先决条件
您需要提供以下内容
- 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