이메일 업그레이드

문서

변경된 사항

  • 메서드 이름과 라이브러리 로드 방법과 같은 소소한 부분만 변경되었습니다.

  • SMTP 프로토콜 사용 시 동작이 약간 변경되었습니다. CI3 설정을 사용하면 SMTP 서버와 제대로 통신하지 못할 수 있습니다. SMTP 프로토콜의 SSL과 TLS 비교이메일 기본 설정를 참조하십시오.

업그레이드 가이드

  1. 클래스 내에서 $this->load->library('email');$email = service('email');로 변경하십시오.

  2. 그 이후 $this->email로 시작하는 모든 줄을 $email로 교체해야 합니다.

  3. Email 클래스의 메서드 이름이 약간 다릅니다. send(), attach(), printDebugger(), clear()를 제외한 모든 메서드는 이전 메서드 이름 앞에 set 접두사가 붙습니다. bcc()는 이제 setBcc()이 되는 식입니다.

  4. app/Config/Email.php의 설정 속성이 변경되었습니다. 새 속성 목록은 이메일 기본 설정를 참조하십시오.

코드 예제

CodeIgniter 버전 3.x

<?php

$this->load->library('email');

$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

$this->email->send();

CodeIgniter 버전 4.x

<?php

$email = service('email');

$email->setFrom('your@example.com', 'Your Name');
$email->setTo('someone@example.com');
$email->setCC('another@another-example.com');
$email->setBCC('them@their-example.com');

$email->setSubject('Email Test');
$email->setMessage('Testing the email class.');

$email->send();