承接 shepherdmat/emaillabs-symfony-mailer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shepherdmat/emaillabs-symfony-mailer

Composer 安装命令:

composer require shepherdmat/emaillabs-symfony-mailer

包简介

This bundle provides Emaillabs integration for Symfony Mailer

README 文档

README

Provides Emaillabs integration for Symfony Mailer.

Installation

The preferred method of installation is via [Composer][]. Run the following command to install the package and add it as a requirement to your project's composer.json:

composer require shepherdmat/emaillabs-symfony-mailer

Usage

Symfony project.

If you want to use it in your standard Symfony project, it's easy:

Add parameters to your local .env file:

# .env
MAILER_DSN=emaillabs://yourAppKey:yourSecretKey@yourActiveHostAccount.smtp

Update services.yaml

# config/services.yaml
services:
    Shepherdmat\Symfony\Mailer\Emaillabs\Transport\EmaillabsTransportFactory:
        tags: [ 'mailer.transport_factory' ]

Now you can follow example from official Symfony Mailer site.

Standalone mailer.

If you want to send email using standard SymfonyHttpClient as http interface:

// require_once __DIR__ . './vendor/autoload.php';

use Shepherdmat\Mailer\Emaillabs\Transport\EmaillabsApiTransport;
use Shepherdmat\Mailer\Emaillabs\Transport\EmaillabsTransportFactory;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\Mailer\Transport\Dsn;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mime\Email;

// Your active host account (https://panel.emaillabs.net.pl/pl/smtp).
$host = 'YOUR_ACCOUNT.smtp';

// Your App Key (https://panel.emaillabs.net.pl/pl/site/api).
$appKey = 'XXXXXXX';

// Your Secret Key (https://panel.emaillabs.net.pl/pl/site/api).
$appSecret = 'YYYYYYY';

$transportFactory = new EmaillabsTransportFactory(null, HttpClient::create());
$dsn = new Dsn(EmaillabsTransportFactory::SCHEME, $host, $appKey, $appSecret);

$mailer = new Mailer($transportFactory->create($dsn));

$message = (new Email())
    ->from('foo@bar.dev')
    ->to('bar@foo.dev')
    ->subject('Message title')
    ->html('<b>HTML message content</b>')
    ->text('Text message content')
    // Attachments are handled by default.
    ->attachFromPath('./path/to/attachment')
    ->embedFromPath('./path/to/attachment', 'embed_tag');
    

// If you want to pass some api parameters, use dedicated headers.
// (https://dev.emaillabs.io/#api-Send-new_sendmail)
$message->getHeaders()
    // Comma-separated list of tags.
    ->addTextHeader(EmaillabsApiTransport::HEADER_TAGS, 'tag1,tag2,tag3')
    // Custom template ID.
    ->addTextHeader(EmaillabsApiTransport::HEADER_TEMPLATE, 'template_id')
    // Custom return path.
    ->addTextHeader(EmaillabsApiTransport::HEADER_RETURN_PATH, 'return_path');

$mailer->send($message);

License

This bundle is under the MIT license.
For the whole copyright, see the LICENSE file distributed with this source code.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固