php - Mandrill 不会替换 html 模板中的合并标签内容

标签 php api mandrill

     Mandrill API Logs  -- 

"subject": "Valentine’s Day special offer. Additional 10% off* on select categories! View exclusive online offer",
        "from_email": "[email protected]",
        "from_name": "zipp",
        "to": [
            {
                "email": "[email protected]",
                "name": "venk",
                "type": "to"
            }
        ],
        "merge": true,
        "merge_vars": [
            {
                "rcpt": "[email protected]",
                "vars": [
                    {
                        "name": "UNSUB",
                        "content": "http://zyr.com/unsubscribe/GYT786HHG"
                    },
                    {
                        "name": "FirstName",
                        "content": "venk"
                    }
                ]
            }
        ],

    "async": false,
    "ip_pool": null,
    "send_at": null,

And when I click on the unsubscriber link in the template, it takes me to the url http://*|unsub|*. Mandrill is not replacing |UNSUB| with http://zyr.com/unsubscribe/GYT&786HHG. Please help me . I spent a lot of time on it, but am unable to solve it

                <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width:100%;" class="mcnTextContentContainer">
                    <tbody><tr>

                        <td valign="top" class="mcnTextContent" style="padding-top:9px; padding-right: 18px; padding-bottom: 9px; padding-left: 18px;">

                            You can&nbsp;<a href="*|UNSUB|*" target="_blank">unsubscribe</a><br>
<br>
&nbsp;
                       </td>
                    </tr>
                </tbody></table>
            </td>
        </tr>
    </tbody>
</table>

最佳答案

无需将 UNSUB 作为合并变量传递。 Mandrill takes care of all of that for you 。 UNSUB 也是一个保留的合并标记,这就是为什么它不会被您在 API 调用中传递的值替换的原因。

因此,在您的 API 调用中,完全删除合并变量:

 {
                    "name": "UNSUB",
                    "content": "http://zyr.com/unsubscribe/GYT786HHG"
                },

在您的 HTML 模板中,使用以下内容:

You can&nbsp;<a href="*|UNSUB:http://zyr.com/unsubscribe/GYT786HHG|*" target="_blank">unsubscribe</a><br>

关于php - Mandrill 不会替换 html 模板中的合并标签内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35292759/

相关文章:

ruby-on-rails - 在 Rails 中发送电子邮件时事通讯/调查

php - 用 sprintf 在左边填充时间?

php - __autoload 在使用 PHPUnit 进行测试时不受尊重

PHP 插入和左连接

java - Adhaar 卡 API

android - 检查应用程序在不同 API 版本/屏幕分辨率下的外观

php - 使用 Mandrill api 更改格式发送邮件

php - 如何让这个for循环从1计数到8?

arrays - 另一个数组中的数组

mandrill - 是否可以为 Mandrill 创建一个 "development"API key ?