我使用Codeigniter3,wamp(php7,MySQL,Apache)
之前没有问题。我在php.ini文件中取消注释extension = php_openssl.dll
行。现在发送电子邮件显示以下错误消息:
1. 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
2. Message: fsockopen(): Failed to enable crypto
Filename: libraries/Email.php
Line Number: 2055
3. Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error)
Filename: libraries/Email.php
Line Number: 2055
和我的电子邮件发送代码:
function mailConfig(){
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'user@gmail.com';
$config['smtp_pass'] = 'password';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['crlf'] = '\r\n'; //should be "\r\n"
$config['newline'] = '\r\n';
$this->load->library("email");
$this->email->initialize($config);
}
/**
* User: 김용식
* 메일 전송
*/
function sendmail($title, $message, $file_path){
$this->mailConfig();
$this->email->clear();
$this->email->to("dydtlr19@gmail.com");
$this->email->from("mail.stccorp@gmail.com");
$this->email->subject($title);
$this->email->message($message);
if($file_path != ''){
$this->email->attach($file_path);
}
if (!$this->email->send()){
echo $this->email->print_debugger();
// echo "<script>alert(\"전송에 실패했습니다.\");</script>";
} else{
echo $this->email->print_debugger();
// echo "<script>alert(\"전송하였습니다.\");</script>";
}
}
请帮我解决这个问题。