使用PHP使用Mandrill发送电子邮件 [英] Sending email with Mandrill using PHP

查看:57
本文介绍了使用PHP使用Mandrill发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Mandrill和PHP发送电子邮件,但无法发送.

I'm trying to send email using Mandrill and PHP and I can't get it to send.

我已经从此处下载了PHP API包装器: https://packagist.org/packages/mandrill /mandrill

I've downloaded the PHP API wrapper from here:https://packagist.org/packages/mandrill/mandrill

Mandrill.php在我的根目录中,而Mandrill文件夹在同一目录中.

Mandrill.php is in my root and the Mandrill folder is in the same directory.

这是我的代码:

<?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");

?>

但是不会发送.我不确定失败在哪里.我想念的东西很明显吗?

But it won't send. I'm not sure where the failure is. Is it something obvious I'm missing?

我现在看到了这个问题.

I see the issue now.

我知道发生了什么事!

我改变了

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

$mandrill->messages->send($message, $async=false, $ip_pool=null, $send_at=null);

它有效!

推荐答案

我应该使用

$mandrill->messages->send($message, $async=false, $ip_pool=null, $send_at=null);

一旦我更改了函数调用,邮件就被发送了.

Once I changed the function call the mail was sent.

这篇关于使用PHP使用Mandrill发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆