flowmailer / symfony-flowmailer-mailer
为 Symfony Mailer 提供Flowmailer集成
1.0.1
2022-06-13 07:05 UTC
Requires
- php: ^8.1
- flowmailer/flowmailer-php-sdk: *
- nyholm/psr7: *
- symfony/http-client: *
- symfony/mailer: ^6.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.21
- friendsofphp/php-cs-fixer: ^3.4
- icanhazstring/composer-unused: ^0.7.11
- maglnet/composer-require-checker: ^3.8
- nyholm/symfony-bundle-test: ^1.8
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^9.5
- symfony/console: ^5.4 || ^6.0
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);