gmedia / sendgridfinisher
Sendgrid API 的 Neos.Form finisher
Requires
- neos/form: ^4.0 || ^5.0
- neos/neos: ^4.0 || ^5.0
- sendgrid/sendgrid: ^7.3
Suggests
- gmedia/sendgridfinisher-nodetypes: Adds a NodeBasedFinisher for SendGrid to be used with Neos.Form.Builder
This package is auto-updated.
Last update: 2024-05-20 12:08:09 UTC
README
一组用于 Sendgrid 的 Neos.Form finisher,使用官方 SendGrid 库。使用此包,您现在可以通过 SMTP-API 和传统的 Neos.Form 邮件 finisher 以外,直接使用他们的库发送电子邮件。这使得您可以直接从您的 Neos 安装中发送具有自定义模板、额外标题、变量等功能丰富的电子邮件。
安装
composer require --no-update gmedia/sendgridfinisher
在您的 composer.json 中添加需求后,您可以更新您的 composer.lock 并安装插件。
composer update
用法
要在您的表单配置中使用此 finisher,您只需向其中添加以下定义
finishers: - identifier: 'Gmedia.SendgridFinisher:EmailFinisher' options: templatePathAndFilename: 'resource://Neos.Demo/Private/Templates/ContactForm/Email.txt' subject: 'Contact from neos.io' recipients: - name: 'John Doe' email: 'john.doe@neos.io' senderAddress: 'demo@neos.io' senderName: 'Neos Demo Site' replyToAddress: 'demo-reply@neos.io' attachments: - resource: 'resource://Neos.Demo/Private/Templates/ContactForm/Email.txt'
模板
要使用 Sendgrid 模板,只需将您的 templateId
添加到 options
。
参考
配置
要启用电子邮件传输,您需要将您的 SendGrid API 密钥添加到配置中。
Gmedia: SendgridFinisher: apiKey: ''
finisher 选项
templatePathAndFilename (字符串)
定义电子邮件内容的模板的资源路径。
subject (字符串)
定义电子邮件的主题。
recipients (数组)
您可以添加多个收件人。每个收件人必须看起来像这样,而至少必须提供 email
参数。
recipients: - 'email': 'john@doe.com' 'name': 'John Doe'
carbonCopyRecipients (数组)
见 收件人。
blindCarbonCopyRecipients (数组)
见 收件人。
senderAddress (字符串)
定义将显示为发件人的地址。
senderAddress: 'john.doe@neos.io'
senderName (字符串)
定义将显示为发件人的名称。
senderName: 'John Doe'
replyToAddress (字符串)
定义将设置为接收此邮件回复的地址。
replyToAddress: 'john.doe@neos.io'
substitutions (数组)
SendGrid 允许您在模板中使用变量,称为替换。在此数组中,您可以定义用于渲染模板的键值对。
'substitutions': '%sub1%': 'Johnny' '%sub2%': 'Hello World'
跟踪设置
您可以通过添加以下选项来调整跟踪设置。有关此选项的更多信息,请参阅 官方 SendGrid API 参考。
'trackingSettings': 'click_tracking': 'enable': false 'enable_text': '' 'open_tracking': 'enable': false 'substitution_tag': '' 'subscription_tracking': 'enable': false 'text': '' 'html': '' 'substitution_tag': '' 'ganalytics': 'enable': false 'utm_source': '' 'utm_medium': '' 'utm_term': '' 'utm_content': '' 'utm_campaign': ''
templateId (字符串)
定义 SendGrid 应该用于解析您的电子邮件的模板的 ID。
additionalHeaders (数组)
定义要发送到电子邮件其他头的额外头。
format (字符串)
定义要发送的电子邮件的格式。可以是 plaintext
或 html
。 注意:如果设置为 plaintext
,则将破坏 SendGrid 模板的 HTML 行为!
testMode (布尔值)
如果 true
,则不会发送电子邮件,您将获得电子邮件对象的转储。
attachments (数组)
目前,我们只能测试将资源作为附件添加。可以通过这种方式完成
attachments: - resource: 'resource://Vendor.Site/Private/Folder/Resource.ext'
稍后会增加一个选项,用于发送表单中文件上传字段提供的附件。