2017-02-09 6 views
4
$config = Array(
'protocol' => 'smtp', 
'smtp_host' => 'smtp.gmail.com', 
'smtp_port' => 465, 
'smtp_user' => '[email protected]', 
'smtp_pass' => 'XXXX', 
'mailtype' => 'html', 
'charset' => 'iso-8859-1' 
); 
$this->load->library('email', $config); 
$this->email->set_newline("\r\n"); 

$this->email->from('[email protected]', 'xxxx'); 
$this->email->to($email); 

$this->email->subject('Hi'); 
$this->email->message('Hi'); 

if($this->email->send()) 
{ 
echo 'Your email was sent.'; 
} 

else 
{ 
show_error($this->email->print_debugger()); 
} 

작동하지 않습니다하지만 오류 메시지를 보여줍니다는 fsockopen() : smtp.gmail.com:465에 연결할 수 없습니다 (연결이 거부 됨).SMTP 프로토콜이 CodeIgniter의

여기 해결책을 보았습니다. Sending mail with CodeIgniter using SMTP protocol not working 그러나 작동하지 않으며 php.ini를 찾을 수 없습니다.

+0

로컬로 시도 하시겠습니까? –

+0

localserver 설치된 드라이브/php/php.ini에서 php.in을 찾거나 내 컴퓨터를 입력하고 검색 상자에 Ctrl + F를 누르면 php.ini를 작성하고 결과를 볼 수 있습니다. –

+0

@parvez 아니요. 로컬이 아닙니다. 호스트가 내 컴퓨터에서 찾을 수없는 이유입니다. –

답변

0

나는이 방법을 사용하고 그리고 그것은 나를 위해 일하고 :

$config = array(
     'protocol' => 'smtps', 
     'smtp_host' => 'ssl://smtps.googlemail.com', 
     'smtp_user' => DONOT_EMAIL, 
     'smtp_pass' => EMAIL_PASSWORD, 
     'smtp_port' => '465', 
     'mailtype' => 'html', 
     'smtp_timeout' => '4', 
     'newline' => "\r\n" 
    ); 

내가 서버 측에 사용이 코드. 로컬 또는 서버에서 메일 기능을 사용할 때마다 확인하십시오. 먼저 다음과 같이 초기화하십시오.

$this->email->initialize($config);