【发布时间】:2014-06-02 20:11:08
【问题描述】:
这个问题和这个Check email template after meta tag replacement and before sending in Mandrill有关。
我想知道是否有一种方法可以将 Mandrill 配置为仅在电子邮件模板中的所有合并标签都已替换时才发送电子邮件。这可能吗?
【问题讨论】:
标签: email mailchimp mandrill email-templates
这个问题和这个Check email template after meta tag replacement and before sending in Mandrill有关。
我想知道是否有一种方法可以将 Mandrill 配置为仅在电子邮件模板中的所有合并标签都已替换时才发送电子邮件。这可能吗?
【问题讨论】:
标签: email mailchimp mandrill email-templates
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
【讨论】: