我试图发送电子邮件使用Mandrill和PHP,我无法让它发送。使用PHP发送电子邮件与Mandrill
我从这里下载的PHP API包装:https://packagist.org/packages/mandrill/mandrill
Mandrill.php是我的根和山魈文件夹是在同一目录下。
这里是我的代码:
<?php
require_once 'Mandrill.php';
$mandrill = new Mandrill('MY API KEY IS USUALLY HERE');
$message = array(
'subject' => 'Test message',
'from_email' => '[email protected]',
'from_name' => 'Sender person',
'html' => '<p>this is a test message with Mandrill\'s PHP wrapper!.</p>',
'to' => array(array('email' => '[email protected]', 'name' => 'Recipient 1')),
'merge_vars' => array(array(
'rcpt' => '[email protected]',
'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));
到
$mandrill->messages->send($message, $async=false, $ip_pool=null, $send_at=null);
和它的作品!
取消注释print_r后得到的结果是什么? – Morgan
您是否尝试过调试?你有没有检查你的错误日志?你有没有检查你的队列中的sendmail(或者你服务器使用的任何机制)? –
@Morgan我采取的代码如何使用PHP从这里发送:http://stackoverflow.com/questions/14473592/simple-php-function-to-send-an-email-with-mandrill/14486237#14486237 但我没有使用模板。所以打印声明现在已被注释掉。 –