flowmailer/symfony-flowmailer-mailer

为 Symfony Mailer 提供Flowmailer集成

安装: 0

依赖者: 0

建议者: 0

安全: 0

星星: 0

关注者: 0

分支: 1

开放问题: 0

类型:symfony-mailer-bridge

1.0.1 2022-06-13 07:05 UTC

This package is auto-updated.

Last update: 2024-09-16 09:43:14 UTC


README

为 Symfony Mailer 提供Flowmailer集成。

安装

composer require flowmailer/symfony-flowmailer-mailer

配置

Flowmailer凭证向导获取凭证

将获取到的凭证添加到env文件中的MAILER_DSN

MAILER_DSN=flowmailer://CLIENT_ID:CLIENT_SECRET@api.flowmailer.net?account_id=1234

在symfony项目中使用时,需要将传输工厂标记为'mailer.transport_factory'。

# config/services.yaml
services:
   # Other services

    Flowmailer\Symfony\Mailer\Transport\FlowmailerTransportFactory:
        parent: 'mailer.transport_factory.abstract'
        tags:
            - name: 'mailer.transport_factory'

独立使用

use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport;
use Flowmailer\Symfony\Mailer\Transport\FlowmailerTransportFactory;

$factory   = new FlowmailerTransportFactory();
$transport = new Transport([$factory]);
$mailer    = new Mailer($transport->fromString($dsnString));

$email = (new Email())
    ->from('example@example.com')
    ->to('example@example.com')
    ->subject('Test e-mail')
    ->text('This is the content of the email')
    ->html('<p>Test e-mail with inline image</p><img src="cid:inline-image">')
    ->attachFromPath('path/to/attachment.pdf')
    ->embedFromPath('path/to/inline-image.png', 'inline-image')
;

$mailer->send($email);