php - 电子邮件 Codeigniter 不工作

标签 php codeigniter email ssl

我正在尝试从我的本地主机向用户发送一封关于他们忘记密码的电子邮件。 (测试) 这个函数在我的 Controller 里

// 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

Severity: Warning

Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

Filename: libraries/Email.php

Line Number: 2055

Backtrace:

File: D:\xampp\htdocs\prototype\application\controllers\Manage.php Line: 191 Function: send

File: D:\xampp\htdocs\prototype\index.php Line: 315 Function: require_once

A PHP Error was encountered Severity: Warning

Message: fsockopen(): Failed to enable crypto

Filename: libraries/Email.php

Line Number: 2055

Backtrace:

File: D:\xampp\htdocs\prototype\application\controllers\Manage.php Line: 191 Function: send

File: D:\xampp\htdocs\prototype\index.php Line: 315 Function: require_once

A PHP Error was encountered Severity: Warning

Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unknown error)

Filename: libraries/Email.php

Line Number: 2055

Backtrace:

File: D:\xampp\htdocs\prototype\application\controllers\Manage.php Line: 191 Function: send

File: D:\xampp\htdocs\prototype\index.php Line: 315 Function: require_once

最佳答案

**试试这个**

    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();

    }

}

关于php - 电子邮件 Codeigniter 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48534124/

相关文章:

php - CodeIgniter 上没有模型对象的数据库查询

Java 正则表达式电子邮件

python - Gmail 不显示内联图片

php - jqgrid 编辑操作如何将变量发送到服务器?

php - 产品类别的 WooCommerce 产品价格中的自定义小数

php - 如何防止 CodeIgniters 打印 PHP 错误

php - Laravel 不会将我的域传递给 MailGun 驱动程序,所以我无法发送邮件

php - 使用 PHP/MySQL 的多级菜单

php - ReflectionException 在 Composer 更新存在的文件时抛出

php - 重新渲染添加元素主干的点击事件