Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Can';t从本地apache服务器使用Mandrill API发送电子邮件_Php_Codeigniter_Api_Email_Mandrill - Fatal编程技术网

Php Can';t从本地apache服务器使用Mandrill API发送电子邮件

Php Can';t从本地apache服务器使用Mandrill API发送电子邮件,php,codeigniter,api,email,mandrill,Php,Codeigniter,Api,Email,Mandrill,我试图使用mandrill api从本地主机发送电子邮件,但每次调用send email函数时,我都会得到“排队”状态。如果我看到mandrillapi日志,我看到调用成功了,而且我没有收到任何电子邮件。这是我正在使用的代码-- 试试看{ $mandrill=新mandrill($this->api\u键); $template_name='investment'; $template\u content=array( 排列( 'name'=>'main', “content”=>“您好*| F

我试图使用mandrill api从本地主机发送电子邮件,但每次调用send email函数时,我都会得到“排队”状态。如果我看到mandrillapi日志,我看到调用成功了,而且我没有收到任何电子邮件。这是我正在使用的代码--

试试看{
$mandrill=新mandrill($this->api\u键);
$template_name='investment';
$template\u content=array(
排列(
'name'=>'main',
“content”=>“您好*| FIRSTNAME |*,我们诚挚地邀请您。”
)
);
$message=数组(
“html'=>”示例html内容,
“文本”=>“示例文本内容”,
“主题”=>“示例主题”,
'来自电子邮件'=>'消息。来自_email@example.com',
'from_name'=>'示例名称',
'到'=>数组(
排列(
'电子邮件'=>'someone@somemail.com',
“名称”=>“收件人名称”,
'键入'=>'到'
)
),
'headers'=>数组('Reply-To'=>'someother@anothermail.com'),
“重要”=>错误,
“轨迹_打开”=>null,
“轨迹单击”=>null,
“自动文本”=>null,
'auto_html'=>null,
'inline_css'=>null,
'url\u strip\u qs'=>null,
“保留收件人”=>null,
“查看内容链接”=>null,
'密件抄送地址'=>'someone@somemail.com',
“跟踪_域”=>null,
“正在签名的\u域”=>null,
“返回路径域”=>null,
“合并”=>true,
“合并语言”=>“邮件黑猩猩”,
“全局合并变量”=>数组(
排列(
'name'=>'merge1',
“内容”=>“合并1内容”
)
),
“合并变量”=>数组(
排列(
“rcpt'=>”another@anothermail.pro',
'vars'=>数组(
排列(
'name'=>'FIRSTNAME',
“内容”=>“我的名字”
)
)
)
),
'tags'=>array('password-resets'),
“子账户”=>“客户-123”,
“谷歌分析域名”=>array('example.com'),
“google\u analytics\u campaign”=>“message.from”_email@example.com',
“元数据”=>array('website'=>www.example.com'),
“收件人\元数据”=>数组(
排列(
“rcpt'=>”收件人。email@example.com',
'values'=>array('user_id'=>123456)
)
),
“附件”=>数组(
排列(
'类型'=>'文本/普通',
'name'=>'myfile.txt',
“内容”=>“ZxHbXbSzSBMAWXL”
)
),
“图像”=>数组(
排列(
'type'=>'image/png',
'name'=>'IMAGECID',
“内容”=>“ZxHbXbSzSBMAWXL”
)
)
);
$async=false;
$ip_池='主池';
$send_at='2014-11-02 01:11:13 PM';
$result=$mandrill->messages->sendTemplate($template\u name、$template\u content、$message、$async、$ip\u pool、$send\u at);
打印(结果);

我试图找到一个解决方案,但仍然没有希望。(这是我第一次使用mandrillapi)“我做了什么错事吗?< /P> < p>看起来你有一个<代码>子帐户< /C>指定,但可能没有一个带有该名称的子帐户。考虑删除任何你实际指定的参数,以确保事情按预期运行。同样,你有一个预定的时间、附件和图像,但是那些AR。e示例,因此您可能希望排除它们。当您包含附件时,邮件将进行异步处理;删除示例邮件将显示更多错误,因为邮件不应再进行异步处理。

尝试使用codeigniter电子邮件库从localhost发送电子邮件非常容易,而且它将100%工作我知道,但我的要求是使用mandrill…无论如何,谢谢如果你能在34小时前提供这个答案,我就可以节省这么长的时间:-(。不管我在不知道问题的情况下解决了这个问题,现在我从你的答案中知道了。
     try {
        $mandrill         = new Mandrill($this->api_key);
        $template_name    = 'Invitation';
        $template_content = array(
            array(
                'name'    => 'main',
                'content' => 'Hi *|FIRSTNAME|*, you are cordially invited.'
            )
        );
        $message          = array(
            'html'                      => '<p>Example HTML content</p>',
            'text'                      => 'Example text content',
            'subject'                   => 'example subject',
            'from_email'                => 'message.from_email@example.com',
            'from_name'                 => 'Example Name',
            'to'                        => array(
                array(
                    'email' => 'someone@somemail.com',
                    'name'  => 'Recipient Name',
                    'type'  => 'to'
                )
            ),
            'headers'                   => array('Reply-To' => 'someother@anothermail.com'),
            'important'                 => false,
            'track_opens'               => null,
            'track_clicks'              => null,
            'auto_text'                 => null,
            'auto_html'                 => null,
            'inline_css'                => null,
            'url_strip_qs'              => null,
            'preserve_recipients'       => null,
            'view_content_link'         => null,
            'bcc_address'               => 'someone@somemail.com',
            'tracking_domain'           => null,
            'signing_domain'            => null,
            'return_path_domain'        => null,
            'merge'                     => true,
            'merge_language'            => 'mailchimp',
            'global_merge_vars'         => array(
                array(
                    'name'    => 'merge1',
                    'content' => 'merge1 content'
                )
            ),
            'merge_vars'                => array(
                array(
                    'rcpt' => 'another@anothermail.pro',
                    'vars' => array(
                        array(
                            'name'    => 'FIRSTNAME',
                            'content' => 'My First Name'
                        )
                    )
                )
            ),
            'tags'                      => array('password-resets'),
            'subaccount'                => 'customer-123',
            'google_analytics_domains'  => array('example.com'),
            'google_analytics_campaign' => 'message.from_email@example.com',
            'metadata'                  => array('website' => 'www.example.com'),
            'recipient_metadata'        => array(
                array(
                    'rcpt'   => 'recipient.email@example.com',
                    'values' => array('user_id' => 123456)
                )
            ),
            'attachments'               => array(
                array(
                    'type'    => 'text/plain',
                    'name'    => 'myfile.txt',
                    'content' => 'ZXhhbXBsZSBmaWxl'
                )
            ),
            'images'                    => array(
                array(
                    'type'    => 'image/png',
                    'name'    => 'IMAGECID',
                    'content' => 'ZXhhbXBsZSBmaWxl'
                )
            )
        );
        $async            = false;
        $ip_pool          = 'Main Pool';
        $send_at          = '2014-11-02 01:11:13 PM';
        $result           = $mandrill->messages->sendTemplate($template_name, $template_content, $message, $async, $ip_pool, $send_at);
        print_r($result);