blue-energy/sendinblue-api-bundle

官方SendinBlue提供的API V2 Symfony 2.x & 3.x Bundle

安装: 3

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 11

类型:symfony-bundle

v2.0.11 2021-01-22 12:39 UTC

README

注意:最新的API V3.0 (LTS) 现在由 https://github.com/sendinblue/ 维护,文档可在以下地址找到 https://developers.sendinblue.com

这是由 SendinBlue 提供的API V2 Symfony Bundle。它实现了各种公开的API,您可以在 https://apidocs.sendinblue.com 上了解更多信息。

这是从 https://github.com/mailin-api/sendinblue-api-bundle 分支出来的。

先决条件

此版本的Bundle需要Symfony 2.x 或 3.x。

安装

使用composer下载SendinBlueApiBundle

在您的 composer.json 中添加SendinBlueApiBundle

        "require": {
            "sendinblue/sendinblue-api-bundle": "2.0.*"
        }
    }```

Now tell composer to download the bundle by running the command:

```bash
$ composer update

或者

运行以下命令进行安装

$ composer require "sendinblue/sendinblue-api-bundle"

Composer会将Bundle安装到您的项目的 vendor/sendinblue 目录中。

启用Bundle

在kernel的 app/AppKernel.php

<?php

public function registerBundles()
{
    $bundles = array(
        // ...
        new SendinBlue\SendinBlueApiBundle\SendinBlueApiBundle(),
    );
}

添加SendinBlue API密钥

在您的 app/config/config.yml

sendin_blue_api:
    api_key: <Your access key>
    # Our library supports a timeout value, which is an optional parameter, default is 30,000 MS ( 30 secs )
    timeout: 5000

用法

API通过 sendinblue_api 服务提供。要访问它,请在控制器(或其他地方)中添加

<?php
$sendinblue = $this->get('sendinblue_api');

示例

获取您的账户信息

<?php
$sendinblue = $this->get('sendinblue_api');

$result = $sendinblue->get_account();
// var_dump($result);

发送电子邮件

<?php

$sendinblue = $this->get('sendinblue_api');

$data = array( "to" => array("to@example.net"=>"to whom!"),
    "cc" => array("cc@example.net"=>"cc whom!"),
    "bcc" => array("bcc@example.net"=>"bcc whom!"),
    "replyto" => array("replyto@email.com","reply to!"),
    "from" => array("from@email.com","from email!"),
    "subject" => "My subject",
    "text" => "This is the text",
    "html" => "This is the <h1>HTML</h1><br/>
               This is inline image 1.<br/>
               <img src=\"{myinlineimage1.png}\" alt=\"image1\" border=\"0\"><br/>
               Some text<br/>
               This is inline image 2.<br/>
               <img src=\"{myinlineimage2.jpg}\" alt=\"image2\" border=\"0\"><br/>
               Some more text<br/>
               Re-used inline image 1.<br/>
               <img src=\"{myinlineimage1.png}\" alt=\"image3\" border=\"0\">",
    "attachment" => array(),
    "headers" => array("Content-Type"=> "text/html; charset=iso-8859-1","X-param1"=> "value1", "X-param2"=> "value2","X-Mailin-custom"=>"my custom value", "X-Mailin-IP"=> "102.102.1.2", "X-Mailin-Tag" => "My tag"),
    "inline_image" => array("myinlineimage1.png" => "your_png_files_base64_encoded_chunk_data","myinlineimage2.jpg" => "your_jpg_files_base64_encoded_chunk_data")
);

$result = $sendinblue->send_email($data);
// var_dump($result);

支持和反馈

请务必访问SendinBlue官方文档网站,获取有关我们API的更多信息。

如果您发现bug,请直接在Github提交问题。

如需进一步帮助,请在此联系我们。