【问题标题】:How can i add parameter in mandrill html text?如何在 mandrill html 文本中添加参数?
【发布时间】:2014-02-07 17:45:49
【问题描述】:

有什么方法可以包含 mandrill 的参数 i html 部分?

我没有使用模板。

这是我的代码。

 $mandrill = new Mandrill('YOUR_API_KEY');
$message = array(
    'html' => '<p>here is my email</p>',
    'text' => 'Example text content',
    'subject' => 'example subject',
    'from_email' => 'message.from_email@example.com',
    'from_name' => 'Example Name',
    'to' => array(
        array(
            'email' => 'recipient.email@example.com',
            'name' => 'Recipient Name',
            'type' => 'to'
        ),
         array(
            'email' => 'recipient.email@example.com',
            'name' => 'Recipient Name',
            'type' => 'to'
        )
    ),

我要做的是在html内容中添加一个参数。

 'html' => '<p>here is my email{ param}</p>', // this line

我该怎么做?

谢谢

【问题讨论】:

    标签: mandrill


    【解决方案1】:

    听起来您正在寻找使用 Mandrill 合并标签。

    您可以在 HTML 内容中插入合并标签,并让它为每个收件人注入个性化信息。它们可以在您的内容中使用,格式为 *|MERGETAG|*,并在您的消息数组中定义“merge_vars”。

    这是他们文档中的一个示例:

    "message": {
            "global_merge_vars": [
                {
                    "name": "var1",
                    "content": "Global Value 1"
                }
            ],
            "merge_vars": [
                {
                    "rcpt": "emailadress@domain.com",
                    "vars": [
                        {
                            "name": "fname",
                            "content": "John"
                        },
                        {
                            "name": "lname",
                            "content": "Smith"
                        }
                    ]
                }
            ],
    

    来源: http://help.mandrill.com/entries/21678522-How-do-I-use-merge-tags-to-add-dynamic-content-

    在测试中,Mandrill 实际上支持一些“开箱即用”的合并标签,所以你应该能够将 *|EMAIL|* 添加到你的 HTML 内容中,它会从你的TO 数组。

    【讨论】:

      猜你喜欢
      • 2011-09-18
      • 2015-06-16
      • 1970-01-01
      • 2021-11-11
      • 2022-10-07
      • 1970-01-01
      • 1970-01-01
      • 2022-07-06
      • 2010-10-26
      相关资源
      最近更新 更多