我正在尝试使用Mandrill和PHP发送电子邮件,但无法发送。
我从这里下载了PHP API封装程序:https://packagist.org/packages/mandrill/mandrill Mandrill.php位于我的根目录中,而Mandrill文件夹与之在同一目录中。
以下是我的代码:
我从这里下载了PHP API封装程序:https://packagist.org/packages/mandrill/mandrill Mandrill.php位于我的根目录中,而Mandrill文件夹与之在同一目录中。
以下是我的代码:
<?php
require_once 'Mandrill.php';
$mandrill = new Mandrill('MY API KEY IS USUALLY HERE');
$message = array(
'subject' => 'Test message',
'from_email' => 'jwjody@yahoo.com',
'from_name' => 'Sender person',
'html' => '<p>this is a test message with Mandrill\'s PHP wrapper!.</p>',
'to' => array(array('email' => 'jwjody@yahoo.com', 'name' => 'Recipient 1')),
'merge_vars' => array(array(
'rcpt' => 'recipient1@domain.com',
'vars' =>
array(
array(
'name' => 'FIRSTNAME',
'content' => 'Recipient 1 first name'),
array(
'name' => 'LASTNAME',
'content' => 'Last name')
))));
//print_r($mandrill->messages->sendTemplate($template_name, $template_content, $message));
echo ("hello");
?>
但是它没有发送。我不确定失败在哪里。是我忽略了明显的问题吗?
我现在看到问题所在。
现在我知道发生了什么!
我改变了
$mandrill->messages->sendTemplate($template_name, $template_content, $message));
to
$mandrill->messages->send($message, $async=false, $ip_pool=null, $send_at=null);
它可以工作!