【问题标题】:Mandrill mergetags: send email only when all merge tags are replacedMandrill 合并标签:仅在替换所有合并标签时发送电子邮件
【发布时间】:2014-06-02 20:11:08
【问题描述】:

这个问题和这个Check email template after meta tag replacement and before sending in Mandrill有关。

我想知道是否有一种方法可以将 Mandrill 配置为仅在电子邮件模板中的所有合并标签都已替换时才发送电子邮件。这可能吗?

【问题讨论】:

    标签: email mailchimp mandrill email-templates


    【解决方案1】:

    AFAIK 无法使用 Mandrill 进行配置。

    您可以(也许应该)使用 API 执行此操作 - 利用 render 方法预呈现外发电子邮件,然后查找任何未替换的字段。

    function has_merge_tags($string)
    {
        return ( strpos("|*", $string) === false AND strpos("*|", $string) === false);
    }
    
    function send_email($template_code, $merge_fields)
    {
        $mandrill = new Mandrill(APIKEY);
    
        // pre-render the template with the merged fields
        $result = $mandrill->templates->render($name, array(), $merge_fields);
    
        if (has_merge_tags($result['html']))
        {
            // throw exception, log it, whatever
        }
    
        really_send_email($result['html']);   
    }
    

    https://mandrillapp.com/api/docs/templates.php.html#method=render

    【讨论】:

      猜你喜欢
      • 2016-05-19
      • 2015-01-11
      • 2014-04-01
      • 1970-01-01
      • 2013-08-10
      • 2013-10-23
      • 2016-07-16
      • 2020-06-12
      • 2013-11-24
      相关资源
      最近更新 更多