<?php
/**
* Email Class
*
* Created on 2011. 11. 16.
* @author 불의회상 <hoksi2k@hanmail.net>
* @package library
* @subpackage controllers
* @version 1.0
*/
class Email_lib extends CI_Controller {
function __construct() {
parent::__construct();
}
function index() {
// Email library Load
$this->load->library('email');
// 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.');
// 실제 Email 전송시 주석을 삭제 하세요.
// @$this->email->send(); // Error 숨김
ob_start();
print_r($this->email);
$data['default'] = ob_get_contents();
ob_end_clean();
// 이메일 환경 설정
$config['useragent'] = 'Firebird';
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'EUC-KR';
$config['wordwrap'] = TRUE;
// 라이브러리 로드시 설정을 지정해 줄 수 있음
// $this->load->library('email', $config);
$this->email->initialize($config);
// 메일 보내는 사람의 메일주소와 이름을 설정합니다:
$this->email->from('you@example.com', 'Your Name');
// 답신을 받을(reply-to) 메일 주소와 이름을 설정합니다. 설정하지않으면 from 함수에서 제공된 정보를 기본으로 사용하게 됩니다.
$this->email->reply_to('you@example.com', 'Your Name');
// 수신자의 이메일주소를 설정합니다. 하나이상의 주소를 설정할수있으며 , 여러개를 설정할때는 콤마(,)로 구분하여 설정하거나, 배열로 넘겨줄수도 있습니다:
$this->email->to('one@example.com, two@example.com, three@example.com');
// CC 메일주소를 설정합니다. "to" 함수처럼 , 하나이상의 주소를 설정할수있으며 , 여러개를 설정할때는 콤마(,)로 구분하여 설정하거나, 배열로 넘겨줄수도 있습니다
$this->email->cc('another@another-example.com');
// BCC 메일주소를 설정합니다. "to" 함수처럼 , 하나이상의 주소를 설정할수있으며 , 여러개를 설정할때는 콤마(,)로 구분하여 설정하거나, 배열로 넘겨줄수도 있습니다
$this->email->bcc('them@their-example.com');
// 메일 제목을 설정합니다:
$this->email->subject('Email Test');
// 이메일 내용을 설정합니다:
$this->email->message('Testing the email class.');
// HTML 메일을 수신하지 못하는 수신자에게 전달하는경우에 html로 작성된 내용을 대신할 내용을 설정합니다:
$this->email->set_alt_message('This is the alternative message');
// 파일을 첨부할수 있게 해주는 함수입니다. 파일 경로와이름(path/name)을 첫번째 파라미터로 넘겨주세요.
$this->email->attach('/path/to/photo1.jpg');
// 여러개의 파일을 첨부할경우 함수를 여러번 호출해주시면됩니다.
$this->email->attach('/path/to/photo2.jpg');
$this->email->attach('/path/to/photo3.jpg');
// 실제 Email 전송시 주석을 삭제 하세요.
// 메일전송함수입니다. 전송성공여부에 따라서 TRUE / FALSE 를 반환합니다.아래와같이 전송성공여부를 체크하여 적절히 코딩하시면 되겠죠:
// if ( ! $this->email->send())
// {
// 에러 처리용 로직
// }
ob_start();
print_r($this->email);
$data['custom'] = ob_get_contents();
ob_end_clean();
$this->load->view('email_lib_sample', $data);
}
}
<?php $this->load->view('inc/header')?>
<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
<th style="text-align:center" width="50%">기본 설정</th>
<th style="text-align:center" width="50%">사용자 재정의</th>
</tr>
</thead>
<tr>
<td><pre><?php echo $default?></pre></td>
<td><pre><?php echo $custom?></pre></td>
</tr>
</table>
<?php $this->load->view('inc/footer')?>
© Copyright by hoksi(Page rendered in 0.0062 seconds)