azine/email-bundle

Symfony3 Bundle 用于发送 html- & txt-电子邮件(关于您Web应用的活动的通知或计划/汇总的通讯等)给您的用户。

安装次数: 7,735

依赖者: 0

建议者: 0

安全: 0

星级: 64

关注者: 5

分支: 24

公开问题: 0

类型:symfony-bundle

4.0.1 2019-03-20 15:21 UTC

This package is auto-updated.

Last update: 2024-09-08 00:44:54 UTC


README

Symfony2 Bundle 提供以下功能的框架

  • 简化您应用程序内美观的 HTML 电子邮件的渲染和发送
  • 立即或计划/汇总地给收件人发送通知/更新信息。
  • 给希望接收的收件人发送通讯。
  • 在浏览器中预览电子邮件渲染,并给您发送测试邮件,以便在您最喜欢的电子邮件客户端中查看。
  • 在浏览器中查看已发送的电子邮件,以防电子邮件在用户的电子邮件客户端中显示不佳。
  • 将营销活动跟踪与您的分析工具(Google Analytics 或 Piwik 等)链接。
  • 使用您的分析工具(Google Analytics 或 Piwik 等)跟踪电子邮件打开。
  • 与 mailgun.com 等交易电子邮件服务配合良好。

目录

快速入门指南 & 示例

要求

1. Swift-Mailer 配置正常

使用 Swiftmailer 和其配置发送邮件。

因此,symfony/swiftmailer-bundle 必须安装并正确配置。

https://github.com/symfony/SwiftmailerBundle

2. Doctrine 用于通知缓冲区

对于缓冲区通知和网页视图,Notification-/SentEmail-对象(=>Azine\EmailBundle\Entity\Notification/Azine\EmailBundle\Entity\SentEmail)存储在数据库中。到目前为止,仅实现了 doctrine-storage。

3. FOSUserBundle

在其当前版本中,它依赖于 FOSUserBundle,因为它也“美化”了从 FOSUserBundle 发送的邮件,并使用用户提供要发送的邮件的收件人信息(姓名/电子邮件/通知间隔/通讯订阅)。

安装

要使用 Composer 安装 AzineEmailBundle,只需将以下内容添加到您的 composer.json 文件中

// composer.json
{
    require: {
        "azine/email-bundle": "dev-master"
    }
}

然后,您可以通过从您的 composer.json 文件所在的目录运行 Composer 的更新命令来安装新的依赖项。

php composer.phar update

现在,Composer 将自动下载所有必需的文件,并为您安装它们。接下来要做的就是更新您的 AppKernel.php 文件,并注册新的包。AzineEmailBundle 依赖于 KnpPaginatorBundle,因此安装后也需要将其添加到 AppKernel.php 文件中。

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Azine\EmailBundle\AzineEmailBundle(),
    new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
    // ...
);

注册 AzineEmailBundle 的路由

# in app/config/routing.yml

azine_email_bundle:
    resource: "@AzineEmailBundle/Resources/config/routing.yml"
    

配置选项

要使捆绑包与默认设置一起工作,不需要配置选项,但必须配置swiftmailer。

这是配置选项的完整列表及其默认值。

# app/config/config.yml
azine_email:

    # the class of your implementation of the RecipientInterface
    recipient_class:      Acme\SomeBundle\Entity\User # Required

    # the fieldname of the boolean field on the recipient class indicating, that a newsletter should be sent or not
    recipient_newsletter_field:  newsletter

    # the service-id of your implementation of the nofitier service to be used
    notifier_service:     azine_email.example.notifier_service

    # the service-id of your implementation of the template provider service to be used
    template_provider:    azine_email.example.template_provider # Required

    # the service-id of the implementation of the RecipientProviderInterface to be used
    recipient_provider:   azine_email.default.recipient_provider

    # the service-id of the mailer service to be used
    template_twig_swift_mailer:  azine_email.default.template_twig_swift_mailer
    no_reply:             # Required

        # the no-reply email-address
        email:                no-reply@example.com # Required

        # the name to appear with the 'no-reply'-address.
        name:                 'notification daemon' # Required

    # absolute path to the image-folder containing the images used in your templates.
    image_dir:            '%kernel.root_dir%/../vendor/azine/email-bundle/Azine/EmailBundle/Resources/htmlTemplateImages/'

    # list of folders from which images are allowed to be embeded into emails
    allowed_images_folders:  []

    # newsletter configuration
    newsletter:

        # number of days between newsletters
        interval:             '14'

        # time of the day, when newsletters should be sent, 24h-format => e.g. 23:59
        send_time:            '10:00'

    # templates configuration
    templates:

        # wrapper template id (without ending) for the newsletter
        newsletter:           'AzineEmailBundle::newsletterEmailLayout'

        # wrapper template id (without ending) for notifications
        notifications:        'AzineEmailBundle::notificationsEmailLayout'

        # template id (without ending) for notification content items
        content_item:         'AzineEmailBundle:contentItem:message'

    # the parameters for link tracking. see https://support.google.com/analytics/answer/1033867 for more infos.
    tracking_params_campaign_name:    utm_campaign #defaluts to utm_name, piwik and google analytics both understand these parameters
    tracking_params_campaign_term:    utm_term     #defaluts to utm_term, piwik and google analytics both understand these parameters
    tracking_params_campaign_content: utm_content  #defaluts to utm_content, piwik and google analytics both understand these parameters
    tracking_params_campaign_medium:  utm_medium   #defaluts to utm_medium, piwik and google analytics both understand these parameters
    tracking_params_campaign_source:  utm_source   #defaluts to utm_source, piwik and google analytics both understand these parameters

    # See the chapter further below for more information
    email_open_tracking_url:  null

    # Defaults to the AzineEmailOpenTrackingCodeBuilder. Depending on the email_open_tracking_url it will create tracking images for piwik or google analytics. 
    email_open_tracking_code_builder:  azine.email.open.tracking.code.builder.ga.or.piwik

    # number of days that emails should be available in web-view
    web_view_retention:   90

    # the service-id of your implementation of the web view service to be used
    web_view_service:     azine_email.example.web_view_service

AzineEmailBundle中的某些操作使用iframe(例如电子邮件仪表板),请确保X-Frame-Options未设置为DENY

    Header set X-Frame-Options DENY

应设置为SAMEORIGIN以允许来自您域的iframe

    Header set X-Frame-Options SAMEORIGIN

有关X-Frame-Options的更多信息,请参阅

https://mdn.org.cn/docs/Web/HTTP/Headers/X-Frame-Options

自定义电子邮件内容和主题

您必须实现自己的通知者服务版本,在其中您可以将通知或时事通讯电子邮件的内容汇总在一起。在AzineNotifierService的子类中,您可以/应该实现以下函数

  • getVarsForNotificationsEmail => 所有通知接收者都使用的变量,您在twig模板中使用这些变量
  • getRecipientVarsForNotificationsEmail => 通知中用于特定接收者的变量,您在twig模板中使用这些变量
  • getRecipientSpecificNotificationsSubject => 通知电子邮件的主题
  • getGeneralVarsForNewsletter => 所有时事通讯接收者都使用的变量,您在twig模板中使用这些变量
  • getNonRecipientSpecificNewsletterContentItems => 所有时事通讯接收者都相同的内容项
  • getRecipientSpecificNewsletterParams => 您在twig模板中使用特定于接收者的变量
  • getRecipientSpecificNewsletterContentItems => 特定接收者的内容项
  • getRecipientSpecificNewsletterSubject => 特定接收者的时事通讯主题

请参阅ExampleNotifierService.php以获取示例。

自定义电子邮件布局

您可以通过三种方式自定义电子邮件的布局

  • 通过编写自己的TemplateProviderInterface实现来定义自己的样式
  • 使用您自己的图片
  • 创建您自己的html和txt twig模板。

这里提供了一个概述,您应该扩展的类中包含有关如何使用文档的更多说明。

您自己的 TemplateProviderInterface 实现

此捆绑包包括一个模板提供者的默认实现(Services/AzineTemplateProvider),以及一个自定义示例(Services/ExampleTemplateProvider)。

请记住,大多数电子邮件查看器中不工作css样式。您需要将一切嵌入到html元素的属性(例如“style”)中,不要使用div元素,因为它们在许多查看器中无法正确显示。使用表格(<table><tr><td>等)来布局您的电子邮件。

例如:<table width="100%"><tr><td height="20" style="font-size: 12px; color: blue;">Bla bla</td></tr></table>

您可以在电子邮件中定义要使用的样式和html代码块。例如,使用不同灰度的背景颜色实现的阴影,通过td元素实现。=>请参阅AzineTemplateProvider类中的"leftShadow"和"cellSeparator"。

您自己的图片

您可以使用自己的图片,这些图片将被嵌入到电子邮件中。为此,只需在您的config.yml中定义图像文件夹的路径即可。=>请参阅上面。

某些(Web-)电子邮件客户端(例如gmail/thunderbird)将正确显示这些嵌入的图片,而无需询问接收者是否希望显示附加的图片。

但是,据我所知,这仅在客户端可以看到只有一个电子邮件接收者,并且“from”地址与发送邮件的帐户相匹配时才有效。有很多原因可能导致图片不显示,因此请确保您的邮件在没有图片的情况下看起来也很好。

您自己的 Twig 模板

此捆绑包需要两种类型的模板,并且每种类型都需要html和txt内容。

1. 包装模板

这些模板包含一个标题部分(徽标等)、标题内容部分(“这是我们的时事通讯blablabla”)、主要内容(请参阅下面的“内容项模板”)和页脚(链接等)。

它们包含通常对于每个电子邮件接收者都完全相同的内容(除问候语外)。

此捆绑包将渲染包含html部分和纯文本部分的电子邮件。

本包中提供的baseEmailLayout-template被分为两个文件baseEmailLayout.txt.twigbaseEmailLayout.html.twig,以便更容易扩展和管理。*.txt.twig包含所需的块,而*.html.twig包含在*.txt.twig模板的body_html-block中。

"*.txt.twig"是用于渲染的模板。它必须包含以下块:

  • 主题
  • 文本正文
  • HTML正文

2. 内容项模板

在一个新闻简报或通知电子邮件中,你可能希望包含不同类型的条目。

例如,在一个更新用户信息的电子邮件中,你可以提到6条私人消息、3个事件和2篇新闻文章。

对于这三种内容条目类型,你可以定义不同的"内容条目模板"和不同的样式。

"私人消息"的示例包括=> Resources/views/contentItem/message.txt.twigResources/views/contentItem/message.html.twig

对于一种内容条目类型,你必须始终提供一个HTML版本和TXT版本。它们将通过其完整的ID进行引用,不带.format.twig结尾。

=> "AzineEmailBundle:contentItem:message" 对于 Resources/views/contentItem/message.txt.twigResources/views/contentItem/message.html.twig

在渲染这些模板时,你可以访问在您的TemplateProvider中为该模板定义的样式和片段。

使您的电子邮件在网页视图和网页预览中可用

在"web预览"中,您可以在发送之前查看电子邮件的内容和布局,并且可以向您的电子邮件地址发送测试电子邮件,以在您喜欢的电子邮件客户端中查看。

在"web查看"中,如果用户的电子邮件客户端破坏了布局,阅读您电子邮件的用户可以查看电子邮件。该捆绑包在您的电子邮件顶部添加了一个链接,以将用户直接导向web查看:"如果此电子邮件未正确显示,请查看网络版"。

配置网页视图和网页预览

为了使用web查看,您必须

  1. 实现自己的WebViewServiceInterface版本。为了减少您的努力,您可以继承AzineWebViewService
  2. 在您的services.yml中将其配置为服务,并将其
  3. 在您的config.yml中设置为azine_email_web_view_service

您可以通过设置azine_email_web_view_retention的值来定义发送的邮件应保留多少天。默认为90天。

web查看使用以下路由:

// ...EmailBundle/Resources/config/routing.yml
# route for users to see an emails
azine_email_webview:
    pattern:  /email/webview/{token}
    defaults: { _controller: "AzineEmailBundle:AzineEmailTemplate:webView" }
    
# route for images that were embeded in emails and now must be shown in web-view
azine_email_serve_template_image:
    pattern:  /email/image/{folderKey}/{filename}
    defaults: { _controller: "AzineEmailBundle:AzineEmailTemplate:serveImage"}

# index with all the email-templates you configured in you implementation of `WebViewServiceInterface`
azine_email_template_index:
    pattern:  /admin/email/
    defaults: { _controller: "AzineEmailBundle:AzineEmailTemplate:index" }
    
# preview of a template filled with dummy-data ... this should probably only be accessible by admins
azine_email_web_preview:
    pattern:  /admin/email/webpreview/{template}/{format}
    defaults: { _controller: "AzineEmailBundle:AzineEmailTemplate:webPreView", format : null }

# route to send test-mails filled with dummy-data ... this should probably only be accessible by admins
azine_email_send_test_email:
    pattern:  /admin/email/send-test-email-for/{template}/to/{email}
    defaults: { _controller: "AzineEmailBundle:AzineEmailTemplate:sendTestEmail", email: null}

要使用web查看,您必须启用这些路由,通过在您的配置中包含路由文件来实现。

// app/config/routing.yml
...
azine_email_bundle:
    resource: "@AzineEmailBundle/Resources/config/routing.yml"
    prefix:   /{_locale}/
    requirements:
        culture:  en|de
...

实现 WebViewServiceInterface

对您来说,最简单的方法是扩展AzineWebViewService并实现三个公共函数:

  • public function getTemplatesForWebPreView()
  • public function getTestMailAccounts()
  • public function getDummyVarsFor($template, $locale)以及可能需要收集填充web预览的虚拟数据的任何额外服务的
  • public function __constructor(...)

您可以查看ExampleWebViewService以了解这些函数中的操作。

更新您的数据库

web查看将所有发送的电子邮件存储在数据库中。为了做到这一点,实体SentEmail必须可用。

它在SentEmail.orm.yml中定义,并且您可以通过命令doctrine:schema:update或迁移来更新您的数据库。

定义要存储在网页视图中的邮件

您可以通过覆盖TemplateProvider中的saveWebViewFor($template)函数来决定您希望在web查看中提供的邮件。

有关如何做到这一点的提示,请参阅ExampleTemplateProvider

删除旧的 "SentEmails"

在web查看中可用的已发送电子邮件存储在数据库中。由于您想删除旧邮件,因此有一个Symfony命令可以为您处理。

Symfony控制台命令emails:remove-old-web-view-emails将删除所有在您的config.yml中定义的azine_email_web_view_retention天数之前的"SentEmail"。

您可以为该命令配置一个cron作业定期调用。请参见下方的Cron-Job 示例

操作

从缓冲区文件夹中删除失败的邮件文件

您想发送的一些邮件可能会失败,如果您已将SwiftMailer配置为使用文件队列,则这些邮件的队列文件将保留在名为*.message.sending的队列文件夹中。

运行swiftmailer:spool:send命令将尝试再次发送这些文件,但如果发送失败,您可能会得到一个充满邮件文件的队列文件夹,这些文件总是失败。

要删除这些文件,您可以使用该包中的emails:clear-and-log-failures命令。

为您的应用程序添加一个cron作业,每天运行一次,或者如果您有很多失败的邮件,则每小时运行一次。请参见下方的Cron-Job 示例

使用命令的date参数,您可以定义邮件发送器在此命令删除这些邮件之前尝试发送这些邮件的时间长度。

我们在操作中使用的 Cron-Jobs 的示例。

以下是一些如何配置您的cron作业以发送邮件和定期清理的示例。

# Send a newsletter every friday:
0 	10 	* 	* 	5 	/usr/local/bin/php -c /path/to/folder/with/php.ini-file/to/use /path/to/your/application/app/console emails:sendNewsletter -e prod >>/path/to/your/application/app/logs/cron.log 2>&1 

# Send a newsletter every other friday:
0 	10 	* 	* 	5 	[ `expr \`date +\%s\` / 86400 \% 2` -eq 0 ] && /usr/local/bin/php -c /path/to/folder/with/php.ini-file/to/use /path/to/your/application/app/console emails:sendNewsletter -e prod >>/path/to/your/application/app/logs/cron.log 2>&1 

# Send notifications every minute:
# Beware! If processing this command takes longer than 1 minute (e.g. trying to send a lot of notifications in one run), 
# then duplicate emails will be sent, as another run is started every 60s. This issue is fixed in the master branch, but only available for Symfony 2.6
* 	* 	* 	* 	* 	/usr/local/bin/php -c /path/to/folder/with/php.ini-file/to/use /path/to/your/application/app/console emails:sendNotifications -e prod >>/path/to/your/application/app/logs/cron.log 2>&1 

# Delete old web-view-emails every night:
0 	3 	1 	* 	* 	/usr/local/bin/php -c /path/to/folder/with/php.ini-file/to/use /path/to/your/application/app/console emails:remove-old-web-view-emails -e prod >>/path/to/your/application/app/logs/cron.log 2>&1 

# Try to re-send failed messages every night:
1 	4 	* 	* 	* 	/usr/local/bin/php -c /path/to/folder/with/php.ini-file/to/use /path/to/your/application/app/console emails:clear-and-log-failures -e prod >>/path/to/your/application/app/logs/cron.log 2>&1 

# If you are spooling emails, then call the send command of the swiftmailer every minute:
* 	* 	* 	* 	* 	/usr/local/bin/php -c /path/to/folder/with/php.ini-file/to/use /path/to/your/application/app/console swiftmailer:spool:send --env=prod >>/path/to/your/application/app/logs/cron.log 2>&1 

TWIG 过滤器

此包还添加了一些在编写邮件时有用的Twig过滤器。

textWrap

textWrap过滤器允许您使用php函数wordwrap来包装文本。默认行宽为75个字符。

{{ "This text should be wrapped after 75 characters, as it is too long for just one line. But there is not line break in the text so far" | textWrap }}
or
{{ "This text should be wrapped after 30 characters, as it is too long for just one line. But there is not line break in the text so far" | textWrap(30) }}

urlEncodeText

此过滤器将文本进行URL编码。使用URL编码的文本,您可以创建带有预先填充的主题和正文的mailto链接。

{% set subject = "I love your service. Thanx a lot" | trans | urlEncodeText %}
{% set body = "Hi,\n\nI just wanted to say thank you!\n\nBest regards,\n%username%" | trans({'%username%' : user.name}) | urlEncodeText %}
<a href="mailto:support@azine.com?subject={{ subject }}&body={{ body }}">Mail to us</a>

stripAndConvertTags

在编写HTML邮件时,您应该始终提供与邮件内容相似的文字版本。

如果您没有HTML内容的文字版本,您可以使用此过滤器将HTML代码转换为可接受的形式。

// some.email.txt.twig
{{ htmlContent | stripAndConvertTags }}

这将

  • 将所有“a”HTML元素替换为以下格式构建的文本:“链接文本:url”或仅为“url”,具体取决于链接文本。
  • 删除所有HTML标签 => see strip_tags
  • 将HTML实体替换为原始字符 => see html_entity_decode

addCampaignParamsForTemplate

此过滤器将获取给定twig模板的跟踪活动参数和值,并将它们与给定的活动参数合并。然后,模板中的所有链接都将补充尚未存在的活动参数。

// used for examlpe in Azine/EmailBundle/Resources/views/baseEmailLayout.html.twig
{% filter addCampaignParamsForTemplate(contentItemTemplate, contentItemParams) %}
    {% include contentItemTemplate ~ '.html.twig' with contentItemParams %}
{% endfilter %}

为“常规”和“紧急”电子邮件使用两个不同的邮件发送器

在大多数情况下,您可能更愿意选择UI性能而不是邮件投递速度。例如,对于密码重置或电子邮件确认电子邮件,您希望用户尽快收到邮件,而不是在下一次队列邮件之后。

为了实现这一点,您必须做两件事

  1. 在您的config.yml文件中配置多个swiftmailers(请参见以下示例和https://symfony.ac.cn/doc/2.6/reference/configuration/swiftmailer.html#using-multiple-mailers
  2. 在您的TemplateProvider中定义应立即发送的电子邮件。

以下是config.yml文件的部分内容

# app/config/config.yml
# Swiftmailer Configuration
swiftmailer:
    default_mailer: defaultMailer // name of the default mailer defined below.
    mailers:
        defaultMailer: // you can choose your name for the default mailer
            host:           "%mailer_host%"
            username:       "%mailer_user%"
            password:       "%mailer_password%"
            transport:      "%mailer_transport%"
            port:           "%mailer_port%"
            encryption:     "%mailer_encryption%"
            antiflood:
                threshold:  10
                sleep:      2
            logging:        "%kernel.debug%"

        immediateMailer: // this name is hard-coded in the bundle!
            host:           "%mailer_host%"
            username:       "%mailer_user%"
            password:       "%mailer_password%"
            transport:      "%mailer_transport%"
            port:           "%mailer_port%"
            encryption:     "%mailer_encryption%"
            antiflood:
                threshold:  10
                sleep:      2
            logging:        "%kernel.debug%"


// app/config/config_prod.yml
// for most mails (defaultMailer) use spooling to improve ui responsiveness
// you must configure a cron-job to execute the "swiftmailer:spool:send"-command
swiftmailer:
    mailers:
        defaultMailer:
            spool:
                type: file
                path: "%kernel.root_dir%/spool.mails/prod"


// app/config/config_dev.yml
// make sure dev-environment mails are sent immediately to a developer-account and not to real email-addresses
swiftmailer:
    mailers:
        defaultMailer:
            delivery_address: mail-to-dev-account-spool@your.domain.com

        immediateMailer:
            delivery_address: mail-to-dev-account-nospool@your.domain.com


// app/config/config_test.yml
// don't send mails during test-runs, only spool them in a dedicated directory
swiftmailer:
    mailers:
        defaultMailer:
            spool:
                type: file
                path: "%kernel.root_dir%/spool.mails/test"

        immediateMailer:
            spool:
                type: file
                path: "%kernel.root_dir%/spool.mails/test"

在您的TemplateProvider接口实现中,您可以定义应立即从模板发送而不是队列的电子邮件

// see ExampleTemplateProvider or AzineTemplateProvider for an example
   protected function getParamArrayFor($template){

     ...
        // send some mails immediately instead of spooled
        if($template == self::VIP_INFO_MAIL_TEMPLATE){
            $newVars[self::SEND_IMMEDIATELY_FLAG] = true;
        }
     ...

使用交易电子邮件服务,例如 e mailgun.com

要使用像mailgun.com、postmarkapp.com或madrill.com这样的交易性电子邮件服务发送和跟踪您的电子邮件
可以将SwiftMailer的配置设置为使用它们的SMTP服务器发送电子邮件。

# app/config/config.yml (or imported from your parameters.yml.dist)
swiftmailer:
    host:           "smtp.mailgun.org"
    username:       "postmaster@acme.com"
    password:       "your-secret-mailgun.com-password"
    transport:      "smtp"
    port:           "587"
    encryption:     "tls"

如果您使用免费账户通过mailgun发送邮件,并且希望能够检查日志等,超过两天以上,还可以查看AzineMailgunWebhooksBundle。Mailgun在约两天后将从免费账户删除日志等。使用此包,您可以将事件存储在自己的数据库中,并保留您所需的时间。

PS:请确保您的应用程序有权连接到其他SMTP。这可能在共享主机账户上被阻止。=> 向您的管理员请求取消阻止。

GoogleAnalytics & Piwik:自定义电子邮件链接中的跟踪值

在您的TemplateProvider实现中,您可以实现函数getCampaignParamsFor($templateId, $params)来定义电子邮件内链接中的活动跟踪参数值。

您可以在电子邮件模板级别定义每个跟踪参数的值,对于由多个嵌套内容项组成的电子邮件,您也可以为这些内容项模板定义值。最后,您可以在所有模板中手动将活动参数值添加到单个链接中。

在这个层次结构中(电子邮件模板 > 内容项模板 > 单个链接),如果它们在更细粒度的级别上定义,则值不会被覆盖。您可以在电子邮件的Web预览中检查生成的链接。

使用跟踪图像(例如 piwik 或 google-analytics)进行电子邮件打开跟踪

要能够使用Piwik或GoogleAnalytics(或类似工具)跟踪电子邮件是否已被打开,您可以在配置中指定一个图像跟踪URL。

#app/config/config.yml
azine_email:
  # for GoogleAnalytics
  email_open_tracking_url: "https://#/collect?v=1&..." 

  # for Piwik
  email_open_tracking_url: "https://your.host.com/piwik-directory/piwik.php?idsite={$IDSITE}&bots=1&rec=1"

如果您在config.yml中配置了email_open_tracking_url,则提供的URL将被跟踪参数和值补充,并在电子邮件的HTML代码末尾插入一个HTML img标签。

如果您想更改跟踪图像URL与跟踪参数和值的补充方式,则可以创建并使用自己的EmailOpenTrackingCodeBuilderInterface实现,并更新您的config.yml以使用该实现。

// app/config/config.yml
azine_email:
  # Defaults to the AzineEmailOpenTrackingCodeBuilder. See the README.md file for more information
  email_open_tracking_code_builder:  your.email.open.tracking.code.builder

有关使用图像进行电子邮件跟踪的更多详细信息,请参阅以下链接

跟踪图像也将插入到您的电子邮件的Web预览中,但为了避免错误的跟踪事件,URL将被修改,以便不指向您的电子邮件打开跟踪系统。

贡献

非常欢迎贡献。请Fork存储库,并将您的pull请求针对master分支。

PR应该

  • 包含PR解决的问题或添加到包中的内容(如有适用,请参考现有问题)
  • 包含干净的代码,一些内联文档和phpdocs,没有“纯空白”更改。
  • 遵守Symfony最佳实践和编码风格
  • 包含对新的功能或修复的phpunit测试
  • 在提交PR之前,确保您的分支在travis-ci.org上构建结果为“绿色”

代码风格

您可以使用php-cs-fixer检查代码风格。可选地,您可以设置一个包含php-cs-fixer检查的pre-commit钩子。也请参阅https://github.com/FriendsOfPHP/PHP-CS-Fixer

您需要做的只是将pre-commit.sample文件从commit-hooks/移动到.git/hooks/文件夹,并将其重命名为pre-commit

php-cs-fixer将在您每次提交时检查您添加的代码的风格,并将修正应用于提交。

要手动运行php-cs-fixer,请安装依赖项(composer install)并执行php vendor/friendsofphp/php-cs-fixer/php-cs-fixer --diff --dry-run -v fix --config=.php_cs.dist .

构建状态等。

Build Status Total Downloads Latest Stable Version Scrutinizer Quality Score Code Coverage