我正在尝试使用Mandrill和PHP发送电子邮件,我无法发送它.
我从这里下载了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");
?>
Run Code Online (Sandbox Code Playgroud)
但它不会发送.我不确定失败的地方.是不是很明显我错过了什么?
我现在看到了这个问题.
我看到现在发生了什么!
我变了
$mandrill->messages->sendTemplate($template_name, $template_content, $message));
Run Code Online (Sandbox Code Playgroud)
至
$mandrill->messages->send($message, $async=false, $ip_pool=null, $send_at=null);
Run Code Online (Sandbox Code Playgroud)
它的工作原理!
我应该使用而不是调用 sendTemplate() 函数
$mandrill->messages->send($message, $async=false, $ip_pool=null, $send_at=null);
Run Code Online (Sandbox Code Playgroud)
一旦我更改了函数调用,邮件就被发送了。
| 归档时间: |
|
| 查看次数: |
3090 次 |
| 最近记录: |