sitegeist/neos-symfonymailer

Neos.Fusion.Form动作和PHP中使用symfony mailer组件的连接器

v1.2.0 2023-08-29 13:24 UTC

README

使用来自Neos CMS的Symfony Mailer组件,特别是与Neos.Fusion.Form一起使用,但也可以直接通过PHP使用。

作者和赞助商

本软件包的开发和公共发布得到了我们雇主http://www.sitegeist.de的大力赞助。

安装

Sitegeist.Neos.SymfonyMailer可通过packagist使用composer require sitegeist/neos-symfonymailer。我们使用语义版本控制,因此每次重大更改都将增加主版本号。

Neos.Fusion.Form动作 Sitegeist.Neos.SymfonyMailer:SendMailAction

Sitegeist.Neos.SymfonyMailer:SendMailAction允许指定在运行时表单成功提交后要发送的电子邮件。

选项

  • senderAddress: (string|array)
  • senderName: (string)
  • recipientAddress: (string|array)
  • recipientName: (string)
  • replyToAddress: (string|array)
  • carbonCopyAddress: (string|array)
  • blindCarbonCopyAddress: (string|array)
  • subject: (string) 电子邮件主题
  • text: (string) 纯文本内容
  • html: (string) HTML内容(如果定义了texthtml,则创建多部分电子邮件)
  • attachments.[key]: (string) 将字符串视为附件读取的路径。
  • attachments.[key]: (UploadedFileInterface|FlowResource) 将上传的文件或资源添加到邮件
  • attachments.[key]: (array{name:string, content:string}) 从namecontent动态创建文件
  • attachments.[key]: (iterable) 如果传递可迭代的(集合),则递归地附加文件
  • testMode: (boolean) 显示调试信息而不是实际发送电子邮件。
  • dsn: (string) 使用指定的邮件器dsn而不是全局设置

示例

form = Neos.Fusion.Form:Runtime.RuntimeForm {
    # ... 
    actions {
        type = 'Sitegeist.Neos.SymfonyMailer:SendMail'
        options {
            senderAddress = ${q(node).property('mailFrom')}
            recipientAddress = ${q(node).property('mailTo')}

            subject = ${q(node).property('mailSubject')}
            text = afx`Thank you {data.firstName} {data.lastName} from {data.city}, {data.street}`
            html = afx`<h1>Thank you {data.firstName} {data.lastName}</h1><p>from {data.city}, {data.street}</p>`

            attachments {
                upload = ${data.file}
                resource = "resource://Form.Test/Private/Fusion/Test.translation.csv"
                jsonFile {
                    content = ${Json.stringify(data)}
                    name = 'data.json'
                }
            }
        }
    }
}

配置

该软件包允许通过设置全局配置邮件器使用的dsn。您可以使用symfony在此处记录的dsn规范:https://symfony.ac.cn/doc/current/mailer.html#transport-setup

Sitegeist:
  Neos:
    SymfonyMailer:
      dsn: 'sendmail://default'

通过PHP使用

该软件包基于Sitegeist.Neos.SymfonyMailer.Factories软件包构建,可以直接从php使用。有关如何执行此操作的更多信息,请参阅https://github.com/sitegeist/Sitegeist.Neos.SymfonyMailer.Factories

贡献

我们很乐意接受贡献。请发送给我们pull请求。

许可协议

LICENSE