안녕하세요
바로 아래에 메일발송 관련해서 질문을 남겼구요
오늘도 이것저것 알아보면서 모르겠어서 다시 올립니다.
캡쳐 사진이 작아서 잘안보이실가봐 텍스트로 남기겠습니다.
메일 발송을 하면 아래와 같이 오류가 발생합니다.
A PHP Error was encountered
Severity: Warning
Message: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Filename: libraries/Email.php
Line Number: 2006
Backtrace:
File: C:\Bitnami\wampstack-7.3.11-0\apache2\htdocs\ci\www\app\controllers\Blog.phpLine: 61Function: send
File: C:\Bitnami\wampstack-7.3.11-0\apache2\htdocs\ci\www\index.phpLine: 315Function: require_once
그러나 같은 소스라도 리눅스 서버(우분투), MAC OSX에서는 정상적으로 메일이 발송합니다.
윈도우에서만 저 오류가 발생합니다. ㅠㅠ
윈도우에서 valet나 비트나미에서 했을 때 모두 저렇게 나오구, https로 테스트해도 저럽니다.
소스를 다시 한번 올리겠습니다.
config/email.php
<?php $config['mailtype'] = 'html'; $config['protocol'] = 'smtp'; $config['charset'] = 'utf-8'; $config['smtp_host'] = 'smtp.gmail.com'; $config['smtp_user'] = '메일아이디@gmail.com'; $config['smtp_pass'] = '메일비밀번호'; $config['smtp_port'] = '587'; $config['smtp_timeout'] = 10; //$config['smtp_crypto'] = 'ssl'; $config['smtp_crypto'] = 'tls'; $config['newline'] = "\r\n"; //$config['validate'] = FALSE;
컨트롤러 로직
public function insert()
{
...생략
// 이메일 보내기
$this->load->library('email');
$this->email->from('메일주소'', "테스터");
$this->email->to('메일주소');
$this->email->subject('코드이그나이터 프레임워크 사용하기: smtp mail 테스트');
$this->email->message('코드이그나이터 정복 하기! ㅎㅎ');
$result = $this->email->send();
}
다른 os에서는 발송이 되면 ci의 문제라기 보다는 윈도우 문제이고 다음 링크를 참고해보세요.
https://stackoverflow.com/questions/47744861/ssl-operation-failed-in-codeigniter
https://php.developreference.com/article/12881050/Send+email+using+XAMPP+and+codeigniter