【问题标题】:Schedule email using wpMandrill to Wordpress使用 wpMandrill 将电子邮件安排到 Wordpress
【发布时间】:2016-02-23 15:25:43
【问题描述】:

是否可以使用 wpMandrill 插件来安排消息?

我在post 中看到我们可以使用 mandrill_payload 过滤器来更改结构中的任何内容(遵循 Mandrill 的 API,/messages/send)。

如何更改 send_at 参数以便安排发送电子邮件。

会不会是这样的:

function customFilterSendAt($send_at)
{
  $send_at = "2016-01-23 14:00:00";
  return $send_at;
}

add_filter('mandrill_payload', 'customFilterSendAt');

然后

wp_mail($email_adress, $subj, $body );

?

【问题讨论】:

  • 您需要为此设置一个实际的 cron 作业。

标签: wordpress email plugins mandrill schedule


【解决方案1】:

我发现可以使用 wpMandrill 来安排电子邮件。这个link(检查 aaroneight cmets)帮助了我。

使用 wpMandrill 安排您的电子邮件:

$message = array(
            'subject' => $subj,
            'from_name' => 'From Name',
            'from_email' => 'from_email@example.com',
            'to' => 'to_email@example.com',
            'html' => $body,
            'async' => false,
            'ip_pool' => null,
            'send_at' => '2016-02-24 19:45:00'
);


$sendmessage = wpMandrill::sendEmail($message);

调试:

echo '<pre>'.print_r($sendmessage,true).'</pre>';

输出示例:

Array
(
    [0] => Array
        (
            [email] => to_email@example.com
            [status] => scheduled
            [_id] => db835dfe43cd5d67b3743a30e184f84d
            [reject_reason] => 
        )
)

目前,预定的电子邮件只能通过 Mandrill 的 API 进行管理,因此您不会在 Mandrill 的仪表板中找到它们。

列出您可以使用的预定电子邮件:

$url = 'https://mandrillapp.com/api/1.0/messages/list-scheduled.json';
$key = 'Your API key';
//$to = '';   // optional

$args = array(
    'body' => array(
        'key' => $key
    )
);

$results =  wp_remote_post( $url, $args );
$results = json_decode($results['body']);

输出示例:

Array
(
    [0] => stdClass Object
        (
            [_id] => 1d0xe54f3b759a1153b7a53g3321f4b6
            [created_at] => 2016-02-24 19:30:13
            [send_at] => 2016-02-24 19:42:00
            [from_email] => from_email@example.com
            [to] => to_email@example.com
            [subject] => Email Subject
        )

    [1] => stdClass Object
        (
            [_id] => 1272e526f6924ba096d23146e2dxad4c
            [created_at] => 2016-02-24 19:31:12
            [send_at] => 2016-02-24 19:45:00
            [from_email] => from_email@example.com
            [to] => to_email@example.com
            [subject] => Email Subject
        )
)

【讨论】:

    猜你喜欢
    • 2020-02-23
    • 2017-04-05
    • 1970-01-01
    • 1970-01-01
    • 2012-09-11
    • 2013-10-10
    • 1970-01-01
    • 2012-10-05
    相关资源
    最近更新 更多