【问题标题】:Email Codeigniter Not working电子邮件 Codeigniter 不工作
【发布时间】:2018-07-10 02:07:20
【问题描述】:

我正在尝试从我的本地主机向用户发送一封关于忘记密码的电子邮件。 (测试) 此功能在我的控制器中

// Send Request Email
public function send_email()
{
        $config = Array(
                                        'protocol' => 'smtp',
                                        'smtp_host' => 'ssl://smtp.googlemail.com',
                                        'smtp_port' => 465,
                                        'smtp_user' => '***@gmail.com', // change it to yours
                                        'smtp_pass' => '***', // change it to yours
                                        'mailtype' => 'html',
                                        'charset' => 'iso-8859-1',
                                        'wordwrap' => TRUE
                                    );

        $message = '';
        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        $this->email->from('***@gmail.com', "Mama"); 
        $this->email->to('***@gmail.com');
        $this->email->subject('Mama Needs You');
        $this->email->message($message);

        if($this->email->send())
        {
                echo 'Email sent to Mama.';
        }
        else
        {
                show_error($this->email->print_debugger());
        }
}

一旦用户输入他的电子邮件并单击请求按钮,上面的函数(send_email)将通过 AJAX 调用请求。但是回复是这样的

A PHP Error was encountered

严重性:警告

消息:fsockopen():SSL 操作失败,代码为 1。OpenSSL 错误 消息:错误:14090086:SSL 例程:ssl3_get_server_certificate:证书验证失败

文件名:libraries/Email.php

行号:2055

回溯:

文件:D:\xampp\htdocs\prototype\application\controllers\Manage.php 行:191 功能:发送

文件:D:\xampp\htdocs\prototype\index.php 行:315 功能: 需要一次

遇到 PHP 错误 严重性:警告

消息:fsockopen():启用加密失败

文件名:libraries/Email.php

行号:2055

回溯:

文件:D:\xampp\htdocs\prototype\application\controllers\Manage.php 行:191 功能:发送

文件:D:\xampp\htdocs\prototype\index.php 行:315 功能: 需要一次

遇到 PHP 错误 严重性:警告

消息:fsockopen():无法连接到 ssl://smtp.googlemail.com:465(未知错误)

文件名:libraries/Email.php

行号:2055

回溯:

文件:D:\xampp\htdocs\prototype\application\controllers\Manage.php 行:191 功能:发送

文件:D:\xampp\htdocs\prototype\index.php 行:315 功能: 需要一次

【问题讨论】:

    标签: php codeigniter email ssl


    【解决方案1】:

    **试试这个**

        public function index()
        {
            $config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'smtp3.netcore.co.in',
            'smtp_port' => 25,
            'smtp_user' => 'support@9abusiness.com',
            'smtp_pass' => 'Supp0rt',
            'mailtype'  => 'html', 
            'charset' => 'utf-8',
            'wordwrap' => TRUE
        );
    
            $this->load->library('email',$config);
            $this->email->from('support@9abusiness.com', 'Support');
            $this->email->to('abdularbaaz@gmail.com');
            $this->email->cc('');
            $this->email->bcc('');
    
            $this->email->subject('Test');
            $this->email->message('This is a test email');
    
        if ( ! $this->email->send())
    {
        // Generate error
        echo "Email is not sent!!";
    }
    
            echo $this->email->print_debugger();
    
        }
    
    }
    

    【讨论】:

    • 感谢@pardeep 先生回答我的问题,我在上面尝试了您的代码,这是 AJAX 调用的回复:消息:fsockopen():无法连接到 smtp3.netcore.co。 in:25(连接尝试失败,因为连接的一方在一段时间后没有正确响应,或者连接建立失败,因为连接的主机没有响应。)
    • 无法使用 PHP SMTP 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。
    • 您的配置文件夹中有 email.php 文件吗?也许你的配置有问题。也许你应该试试 $config['mailtype'] = 'text'; mailtype html 已经给我带来了一些问题。或者尝试删除整个配置文件以使用默认设置
    • 我的配置文件夹中没有 email.php.. 我的控制器中只有上面那行代码
    • 我试图删除控制器中的配置代码,但错误与我上面提到的一样:/我觉得绝望
    猜你喜欢
    • 2014-07-05
    • 2015-11-03
    • 1970-01-01
    • 1970-01-01
    • 2011-09-14
    • 1970-01-01
    • 2018-08-06
    • 2016-05-27
    • 2017-10-21
    相关资源
    最近更新 更多