使用Mandrill(php)发送电子邮件时发生错误

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了使用Mandrill(php)发送电子邮件时发生错误脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我第一次使用Mandrill api.我正在使用以下代码.
我有Mandrill API钥匙.
<?PHP
    try {
        $mandrill = new Mandrill('YOUR_API_KEY');
        $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' => 'recipient.email@example.com','name' => 'Recipient Name'
                )
            ),'headers' => array('Reply-to' => 'message.reply@example.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' => 'message.bcc_address@example.com','tracking_domain' => null,'signing_domain' => null,'return_path_domain' => null,'merge' => true,'global_merge_VARs' => array(
                array(
                    'name' => 'merge1','content' => 'merge1 content'
                )
            ),'merge_vars' => array(
                array(
                    'rcpt' => 'recipient.email@example.com','vars' => array(
                        array(
                            'name' => 'merge2','content' => 'merge2 content'
                        )
                    )
                )
            ),'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 = 'example send_at';
        $result = $mandrill->;messages->send($message,$async,$ip_pool,$send_at);
        print_r($result);

    } catch(Mandrill_Error $e) {
        echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();

        throw $e;
    }
    ?>

通过使用这个代码,我得到错误

发生mandrill错误:Mandrill_HttpError – 对消息/发送的API调用失败:错误设置证书验证位置:CAfile:/usr/local/share/certs/ca-root-nss.crt CApath:none

为什么我得到这个错误

错误表明您没有在本地安装所需的SSL证书,以验证与Mandrill API的SSL连接.您可以通过操作系统的软件包管理器获取系列证书,也可以下载Mozilla: http://curl.haxx.se/docs/caextract.html发行的软件包,然后将其存储在本地.

脚本宝典总结

以上是脚本宝典为你收集整理的使用Mandrill(php)发送电子邮件时发生错误全部内容,希望文章能够帮你解决使用Mandrill(php)发送电子邮件时发生错误所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。