我正在尝试从我的本地主机向用户发送一封关于他们忘记密码的电子邮件。 (测试) 这个函数在我的 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/