2

有没有办法通过 Mautic API 发送电子邮件,并通过发送请求在单个请求中发送自己的属性?示例:我想向客户发送带有订单摘要的流程电子邮件。所以我想用ex准备电子邮件模板。{special:orderId}, {special:orderPrice},... 并且想做这样的事情

$api->send(emailId, contactId, [
    special => [
        'orderId' => 123,
        'orderPrice' => 1000
    ]
]);

额外的东西 - 客户在他的收藏夹中有一些我们的电子商店类别,我想发送带有“您最喜欢的类别中的新内容”的基本时事通讯......然后只需选择创建的电子邮件模板并发送参数

$parameters = [
    1 => [
        'name' => 'Product name',
        'price' => 123,
        'imgPath' => 'http://pathToImage'
        ...
    ],
    ...
]

有什么方法可以做到这一点吗?我是 Mautic 的初学者,但我认为它是为这些特色菜设计的,但不知道该怎么做......

非常感谢您的回复。Mautic v. 2.4

4

2 回答 2

4

是的,您可以在电子邮件中使用自定义令牌。但是 API 库不直接支持这一点。您需要将值放在数组结构中并makeRequest()直接调用函数。这是因为 API 库sendToContact()函数没有可选数据的第三个参数。它将一个空数组传递给makeRequest()

/**
 * Send email to a specific contact
 *
 * @param int $id
 * @param int $contactId
 *
 * @return array|mixed
 */
public function sendToContact($id, $contactId)
{
    return $this->makeRequest($this->endpoint.'/'.$id.'/contact/'.$contactId.'/send', array(), 'POST');
}

所以你必须这样称呼它:

    $emailApi = $api->newApi("emails", $auth, $apiUrl);

    $data = array(
        'tokens' => array(
            '{custom_token}' => 'My Custom Token'
        )
    );

    $email = $emailApi->makeRequest('emails/'.$email_id.'/contact/'.$contact_id.'/send', $data, 'POST');

然后您可以在您的电子邮件中使用 {custom_token}。

或者您可以使用sendToContact方法。只需将上面的最后一行替换为如下:

$email = $emailApi->sendToContact($email_id, $contact_id, $data);
于 2018-02-26T17:02:54.033 回答
0

我认为这样的事情是不可能的,但是对于您可以在此处提交的功能请求来说这是一个好主意:https ://github.com/mautic/mautic/issues

您现在必须做的是添加联系人自定义字段,如 orderId 和 orderPrice,进行 API 调用以使用最新订单更新联系人,然后将预定义的电子邮件{contactfield=orderId}{contactfield=orderPrice}令牌发送给联系人和Mautic 将为您处理代币更换。

于 2017-03-03T15:11:18.037 回答