Source for file MTA.php
Documentation is available at MTA.php
* Project: pear Mail Transfer Agent(MTA)<br />
* Dependency: {@link https://github.com/OOPS-ORG-PHP/myException myException}
* MTA는 php mail function을 대체할 수 있으며, smtp server나
* smtp daemon이 없더라도 자체적으로 메일을 발송할 수 있는 기능을
* 또한 alternative/mixed 방식의 mail body를 생성하는 method를 제
* 공하며, 발송 시 중복된 메일 주소를 압축하여 중복된 메일 서버에
* 여러번 접근하지 않도록 최적화 되어 있다.
* {@example MTA/tests/test.php}
* @author JoungKyun.Kim <http://oops.org>
* @copyright (c) 2018, OOPS.org
* @link http://pear.oops.org/package/MTA
* import myException class
* MTA API는 pear.oops.org/myException pear pacage에
require_once 'myException.php';
* import MTA_Generate class
require_once 'MTA/MTA_Generate.php';
* {@example MTA/tests/test.php}
* send method 실행시 debug message 출력
* Mail agent 값. 기본값은 oops\MTA 이다.
* 내부적으로 사용할 socket descriptor
// {{{ (void) MTA::__construct
// {{{ (object) public MTA::send ($o)
* {@example MTA/tests/test.php 22 28}
* @return stdClass 발송 결과를 object로 반환한다.
* [status] => (bool) 성공 실패 여부
* [error] => (string) status false시 에러 메시지
* [rcptlog] => (array) rcpt to에 대한 log
* RCPT list별로 확인을 위해서 status가 true이더라도 rcptlog를
* @param stdClass $o mail object
* [rpath] => (string) return path (optional)
* [from] => (string) Sender address
* [to] => (array) Reciever address
* [cc] => (array) See also reciever address
* [bcc] => (array) Hidden see also reciever address
* [subjet] => (string) mail subject
* [body] => (string) mail contents
* [pbody] => (string) planin/text mail contents (optional)
* [attach] => (array) attached files (optional)
public function send ($o) {
$template = $this->source ($o);
// {{{ (string) public MTA::source ($v)
* 주어진 정보를 이용하여 raw mail body를 alternative/mixed
* {@example MTA/tests/test.php 22 22}
* @return string If occur error, throw excption
* @param stdClass $v mail object
* [from] => (string) Sender address
* [to] => (array) Reciever address
* [cc] => (array) See also reciever address (optional)
* [bcc] => (array) Hidden see also reciever address (optional)
* [subjet] => (string) mail subject
* [body] => (string) mail contents
* [pbody] => (string) planin/text mail contents (optional)
* [attach] => (array) attached files (optional)
foreach ( $v as $key => $val ) {
if ( $key == 'attach' ) {
foreach ( $o->to as $val ) {
foreach ( $o->cc as $val ) {
$o->cc = 'CC: ' . $o->cc . "\r\n";
foreach ( $o->bcc as $val ) {
$this->addr ($val) . ', ';
$o->bcc = 'BCC: ' . $o->bcc . "\r\n";
$o->date = $this->date ();
$o->msgid = $this->msgid ();
$o->subject = $this->encode ($o->subject);
$o->body = $this->encode ($o->body, true);
$o->pbody = $this->encode ($o->pbody, true);
$attaches = $this->attach ($o->attach, $o->boundary);
'/@MESSAGE_ID@/', '/@DATE@/', '/@FROM@/', '/@TO@/', '/@CC@/',
'/@BCC@/', '/@SUBJECT@/', '/@BOUNDARY@/', '/@SUB_BOUNDARY@/',
'/@PLAINBODY@/', '/@BODY@/', '/@ATTCHED@/', '/@MAIL_AGENT@/',
$o->msgid, $o->date, $o->from, $o->to,
$o->cc, $o->bcc, $o->subject, $o->boundary,
$o->subboundary, $o->pbody, $o->body, $attaches,
* vim: set filetype=php noet sw=4 ts=4 fdm=marker:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
|