728x90
반응형
<?php // application/config/email.php $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.googlemail.com'; $config['smtp_port'] = '465'; $config['smtp_timeout'] = '45'; $config['smtp_user'] = 'test@gmail.com'; $config['smtp_pass'] = 'test'; $config['charset'] = 'utf-8'; $config['newline'] = "\r\n";
<?php // application/controller/Email.php class Email extends CI_Controller { public function __construct() { parent::__construct(); } function index() { $this->load->library('email'); $this->email->from('test@gmail.com', '보내는 사람이름'); $this->email->to("test@gmail.com"); $this->email->subject('메일 제목'); $this->email->message("메일 내용"); $result = $this->email->send(); if(!$result) { // 에러가 날 경우 디버그 설정을 해두면 에러내용이 자세히 나온다. echo $this->email->print_debugger(); } } }
저소스만으로 되지 않았다. 아래의 3가지를 gmail에서 설정해줘야 겨우 이메일을 보낼 수 있었다.
1. 보안 수준이 낮은 앱 엑세스 허용
2. 이메일에서의 활동확인
3. 2단계 인증과 앱 비밀번호 설정
참고사이트
728x90
반응형