pendable/symfony-mailer

Symfony Pendable 邮件桥接器

v1.0.1 2023-09-10 12:55 UTC

This package is auto-updated.

Last update: 2024-09-10 15:01:35 UTC


README

提供对 Symfony Mailer 的 Pendable 集成。

Pendable

Pendable 在 Amazon SES 周围提供封装服务,增加了以下功能:并行化邮件发送,优先级排序邮件,将来安排邮件投递,跟踪打开、点击和其他事件,基于您的退订和投诉进行活动节流,过滤垃圾邮件域名,维护健康联系人列表,检索、故障排除和重新发送消息,所有客户沟通的时间线视图。

更多详细信息请访问 pendable.io

安装

在您的项目目录中打开命令行控制台,并执行以下命令以下载此捆绑包的最新稳定版本

$ composer require pendable/symfony-mailer

config/services.php 中添加以下行

<?php
// config/services.php

return [
    Pendable\SymfonyMailer\Transport\PendableTransportFactory:
        tags: [ mailer.transport_factory ]
];

最后,将您的 MAILER_DSN 凭据添加到项目的 .env 文件中

您可以通过配置 DSN 如下使用 HTTP API 传输

MAILER_DSN=pendable+api://$PENDABLE_API_KEY@default

用法

$email = (new Email())
  ->from('mydomain@test.com')
  ->to('to@test.com')
  // ->cc('...')
  // ->addCc('...')
  // ->bcc('...')
  // ->replyTo('...')
  ->subject("Subject")
  ->html('<p>Html content of Symfony Pendable email.</p>')
  ->text('Text content of your Symfony Pendable text-only email.');

$email->getHeaders()
    ->add(new MetadataHeader('key-1', 'value-1')) // Custom field called 'key-1'
    ->add(new MetadataHeader('key-2', 'value-2')) // Custom field called 'key-2'
    ->add(new TagHeader('TagInHeaders1')) // Tags
    ->add(new TagHeader('TagInHeaders2')) // Tags
    ->addTextHeader('priority', 60)
    ->addTextHeader('config_identifier', 'custom key')
    ->addTextHeader('client_email_id', '123476AB')
    ->addTextHeader('schedule_send_at', '2023-06-25T22:37:26+05:30');

// Send the email using the custom Pendable transport
try {
    $resp = $mailer->send($email);
    return new Response('Email sent successfully to Pendable.');
} catch (\Exception $e) {
    return new Response('Failed to send email to Pendable: ' . $e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
}

变更日志

  • v1.0.1 (2023年9月10日)
    • 当某些功能尚不支持 Pendable 时抛出异常
    • 更新了 Readme
  • v1.0.0 (2023年9月1日)
    • 首次发布

资源