未定义的属性:Mandrill :: $ messages

时间:2016-07-20 06:25:58

标签: php mandrill

我正在使用 mandrill API 但获取error:Undefined property: Mandrill::$messages.code:

  $mandrill = new Mandrill('My KEY');        
    $message = array(
        'subject' => 'My subject',
        'from_email' => 'marc@example.com',
        'to' => array(array('email' => 'recipient1@example.com', 'name'=> 'Marc')),
        'merge_vars' => array(array(
            'rcpt' => 'recipient1@example.com',
            'vars' =>
            array(
                array(
                    'name' => 'FIRSTNAME',
                    'content' => 'Recipient 1 first name'),
                array(
                    'name' => 'LASTNAME',
                    'content' => 'Last name')
        ))));

    $template_name = 'Lodging Connection';

    $template_content = array(
        array(
            'name' => 'main',
            'content' => 'Hi *|FIRSTNAME|* *|LASTNAME|*, thanks for signing up.'),
        array(
            'name' => 'footer',
            'content' => 'Copyright 2013.')

    );        
    $response = $mandrill->messages->send($template_name, $template_content, $message);
    print_r($response);

1 个答案:

答案 0 :(得分:1)

要使用模板发送消息,您应使用sendTemplate代替send

$response = $mandrill->messages->sendTemplate($template_name, $template_content, $message);