q-alliance/qsendgridbundle

该包最新版本(1.0.4)没有可用的许可证信息。

QSendgrid邮件服务器的Symfony组件实现

安装: 179

依赖: 0

建议者: 0

安全: 0

星级: 0

关注者: 5

分支: 1

类型:symfony-bundle

1.0.4 2020-07-25 11:41 UTC

This package is not auto-updated.

Last update: 2021-10-02 17:32:38 UTC


README

Symfony组件实现QSendgrid邮件服务。

先决条件

您需要提供以下内容

密钥示例: 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');

作者