23 if (!class_exists(
'SMTP4')) require_once
'SMTP4.php';
53 var
$QMail =
'/var/qmail/bin/sendmail';
63 $this->_mime =
new MIME4;
64 $this->_smtp =
new SMTP4;
65 $this->
_result(array(0 =>
'initialize class'));
68 function _result($data = array(), $ret = null) {
70 $this->Result = $data;
74 function context($arr = null, $debug = null) {
76 if (!is_array($arr))
FUNC4::trace($debug,
'invalid context type');
77 else if (!is_resource($res = stream_context_create($arr)))
FUNC4::trace($debug,
'invalid context value');
79 $this->Context = $res;
80 return $this->
_result(array(0 =>
'set context connection'),
true);
84 function name($host = null, $debug = null) {
86 if (!is_string($host))
FUNC4::trace($debug,
'invalid hostname type');
88 $host = strtolower(trim($host));
91 return $this->
_result(array(0 =>
'set HELO/EHLO hostname'),
true);
95 function path($addr = null, $debug = null) {
97 if (!is_string($addr))
FUNC4::trace($debug,
'invalid address type');
101 return $this->
_result(array(0 =>
'set Return-Path address'),
true);
107 if ($level == null) {
108 $this->Priority = null;
109 return $this->
_result(array(0 =>
'unset priority'),
true);
110 }
else if (is_int($level) || is_string($level)) {
112 if ($level == 1 || $level == 3 || $level == 5 || $level ==
'high' || $level ==
'normal' || $level ==
'low') {
113 $this->Priority = $level;
114 return $this->
_result(array(0 =>
'set priority'),
true);
119 function from($addr = null, $name = null, $charset = null, $encoding = null, $debug = null) {
122 if (!is_string($addr)) $err[] =
'invalid address type';
123 else if (!
FUNC4::is_mail($addr)) $err[] =
'invalid address value';
125 if (!is_string($name)) $err[] =
'invalid name type';
128 if ($name ==
'') $err[] =
'invalid name value';
131 if ($charset != null) {
132 if (!is_string($charset)) $err[] =
'invalid charset type';
133 else if (!(strlen($charset) >= 2 &&
FUNC4::is_alpha($charset,
true,
'-'))) $err[] =
'invalid charset value';
135 if ($encoding != null) {
136 if (!is_string($encoding)) $err[] =
'invalid encoding type';
138 $encoding = strtolower($encoding);
139 if (!isset($this->_mime->hencarr[$encoding])) $err[] =
'invalid encoding value';
142 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
144 $this->From = array(
'address' => $addr,
'name' => $name,
'charset' => $charset,
'encoding' => $encoding);
145 return $this->
_result(array(0 =>
'set From address'),
true);
149 function addto($addr = null, $name = null, $charset = null, $encoding = null, $debug = null) {
152 if (!is_string($addr)) $err[] =
'invalid address type';
153 else if (!
FUNC4::is_mail($addr)) $err[] =
'invalid address value';
155 if (!is_string($name)) $err[] =
'invalid name type';
158 if ($name ==
'') $err[] =
'invalid name value';
161 if ($charset != null) {
162 if (!is_string($charset)) $err[] =
'invalid charset type';
163 else if (!(strlen($charset) >= 2 &&
FUNC4::is_alpha($charset,
true,
'-'))) $err[] =
'invalid charset value';
165 if ($encoding != null) {
166 if (!is_string($encoding)) $err[] =
'invalid encoding type';
168 $encoding = strtolower($encoding);
169 if (!isset($this->_mime->hencarr[$encoding])) $err[] =
'invalid encoding value';
172 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
175 if (count($this->To) > 0) {
176 $ladr = strtolower($addr);
177 foreach ($this->To as
$to) {
178 if ($ladr == strtolower($to[
'address'])) {
179 FUNC4::trace($debug,
'duplicate To address "'.$addr.
'"', 1);
184 if ($find)
return false;
186 $this->To[] = array(
'address' => $addr,
'name' => $name,
'charset' => $charset,
'encoding' => $encoding);
187 return $this->
_result(array(0 =>
'add To address'),
true);
192 function delto($addr = null, $debug = null) {
196 return $this->
_result(array(0 =>
'delete all To addresses'),
true);
202 if (count($this->To) > 0) {
203 $addr = strtolower($addr);
204 foreach ($this->To as
$to) {
205 if ($addr == strtolower($to[
'address'])) $ret =
true;
211 return $this->
_result(array(0 =>
'delete To address'),
true);
212 }
else return FUNC4::trace($debug,
'To address "'.$addr.
'" not found', 1);
216 function addcc($addr = null, $name = null, $charset = null, $encoding = null, $debug = null) {
219 if (!is_string($addr)) $err[] =
'invalid address type';
220 else if (!
FUNC4::is_mail($addr)) $err[] =
'invalid address value';
222 if (!is_string($name)) $err[] =
'invalid name type';
225 if ($name ==
'') $err[] =
'invalid name value';
228 if ($charset != null) {
229 if (!is_string($charset)) $err[] =
'invalid charset type';
230 else if (!(strlen($charset) >= 2 &&
FUNC4::is_alpha($charset,
true,
'-'))) $err[] =
'invalid charset value';
232 if ($encoding != null) {
233 if (!is_string($encoding)) $err[] =
'invalid encoding type';
235 $encoding = strtolower($encoding);
236 if (!isset($this->_mime->hencarr[$encoding])) $err[] =
'invalid encoding value';
239 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
242 if (count($this->Cc) > 0) {
243 $ladr = strtolower($addr);
244 foreach ($this->Cc as $cc) {
245 if ($ladr == strtolower($cc[
'address'])) {
246 FUNC4::trace($debug,
'duplicate Cc address "'.$addr.
'"', 1);
251 if ($find)
return false;
253 $this->Cc[] = array(
'address' => $addr,
'name' => $name,
'charset' => $charset,
'encoding' => $encoding);
254 return $this->
_result(array(0 =>
'add Cc address'),
true);
259 function delcc($addr = null, $debug = null) {
263 return $this->
_result(array(0 =>
'delete all Cc addresses'),
true);
269 if (count($this->Cc) > 0) {
270 $addr = strtolower($addr);
271 foreach ($this->Cc as $cc) {
272 if ($addr == strtolower($cc[
'address'])) $ret =
true;
278 return $this->
_result(array(0 =>
'delete Cc address'),
true);
279 }
else return FUNC4::trace($debug,
'Cc address "'.$addr.
'" not found', 1);
283 function addbcc($addr = null, $debug = null) {
285 if (!is_string($addr))
FUNC4::trace($debug,
'invalid address type');
288 if (count($this->Bcc) > 0) {
289 $ladr = strtolower($addr);
290 foreach ($this->Bcc as $bcc) {
291 if ($ladr == strtolower($bcc)) {
292 FUNC4::trace($debug,
'duplicate Bcc address "'.$addr.
'"', 1);
297 if ($find)
return false;
299 $this->Bcc[] = $addr;
300 return $this->
_result(array(0 =>
'add Bcc address'),
true);
304 function delbcc($addr = null, $debug = null) {
307 $this->Bcc = array();
308 return $this->
_result(array(0 =>
'delete all Bcc addresses'),
true);
314 if (count($this->Bcc) > 0) {
315 $addr = strtolower($addr);
316 foreach ($this->Bcc as $bcc) {
317 if ($addr == strtolower($bcc)) $ret =
true;
323 return $this->
_result(array(0 =>
'delete Bcc address'),
true);
324 }
else return FUNC4::trace($debug,
'Bcc address "'.$addr.
'" not found', 1);
328 function addheader($name = null, $value = null, $charset = null, $encoding = null, $debug = null) {
331 if (!is_string($name)) $err[] =
'invalid name type';
334 if (!(strlen($name) >= 2 &&
FUNC4::is_alpha($name,
true,
'-'))) $err[] =
'invalid name value';
336 if (!is_string($value)) $err[] =
'invalid content type';
339 if ($value ==
'') $err[] =
'invalid content value';
341 if ($charset != null) {
342 if (!is_string($charset)) $err[] =
'invalid charset type';
343 else if (!(strlen($charset) >= 2 &&
FUNC4::is_alpha($charset,
true,
'-'))) $err[] =
'invalid charset value';
345 if ($encoding != null) {
346 if (!is_string($encoding)) $err[] =
'invalid encoding type';
348 $encoding = strtolower($encoding);
349 if (!isset($this->_mime->hencarr[$encoding])) $err[] =
'invalid encoding value';
352 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
354 $ver = strtolower($name);
356 if ($ver ==
'to') $err =
'can not set "To", for this, use function "AddTo()"';
357 else if ($ver ==
'cc') $err =
'can not set "Cc", for this, use function "AddCc()"';
358 else if ($ver ==
'bcc') $err =
'can not set "Bcc", for this, use function "AddBcc()"';
359 else if ($ver ==
'from') $err =
'can not set "From", for this, use function "From()"';
360 else if ($ver ==
'subject') $err =
'can not set "Subject", for this, use function "Subject()"';
361 else if ($ver ==
'x-priority') $err =
'can not set "X-Priority", for this, use function "Priority()"';
362 else if ($ver ==
'x-msmail-priority') $err =
'can not set "X-MSMail-Priority", for this, use function "Priority()"';
363 else if ($ver ==
'x-mimeole') $err =
'can not set "X-MimeOLE", for this, use function "Priority()"';
364 else if ($ver ==
'date') $err =
'can not set "Date", this value is automaticaly set';
365 else if ($ver ==
'content-type') $err =
'can not set "Content-Type", this value is automaticaly set';
366 else if ($ver ==
'content-transfer-encoding') $err =
'can not set "Content-Transfer-Encoding", this value is automaticaly set';
367 else if ($ver ==
'content-disposition') $err =
'can not set "Content-Disposition", this value is automaticaly set';
368 else if ($ver ==
'mime-version') $err =
'can not set "Mime-Version", this value is automaticaly set';
369 else if ($ver ==
'x-mailer') $err =
'can not set "X-Mailer", this value is automaticaly set';
370 else if ($ver ==
'message-id') $err =
'can not set "Message-ID", this value is automaticaly set';
373 $this->Header[] = array(
'name' => $name,
'value' => $value,
'charset' => $charset,
'encoding' => $encoding);
374 return $this->
_result(array(0 =>
'add header'),
true);
382 $this->Header = array();
383 return $this->
_result(array(0 =>
'delete all headers'),
true);
384 }
else if (!(is_string($name) && strlen($name) >= 2 &&
FUNC4::is_alpha($name,
true,
'-'))) {
389 if (count($this->Header) > 0) {
390 $name = strtolower($name);
391 foreach ($this->Header as $header) {
392 if ($name == strtolower($header[
'name'])) $ret =
true;
393 else $new[] = $header;
397 $this->Header = $new;
398 return $this->
_result(array(0 =>
'delete header'),
true);
399 }
else return FUNC4::trace($debug,
'header not found', 1);
403 function subject($content = null, $charset = null, $encoding = null, $debug = null) {
406 if (!is_string($content)) $err[] =
'invalid content type';
409 if ($content ==
'') $err[] =
'invalid content value';
411 if ($charset != null) {
412 if (!is_string($charset)) $err[] =
'invalid charset type';
413 else if (!(strlen($charset) >= 2 &&
FUNC4::is_alpha($charset,
true,
'-'))) $err[] =
'invalid charset value';
415 if ($encoding != null) {
416 if (!is_string($encoding)) $err[] =
'invalid encoding type';
418 $encoding = strtolower($encoding);
419 if (!isset($this->_mime->hencarr[$encoding])) $err[] =
'invalid encoding value';
422 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
424 $this->Subject = array(
'content' => $content,
'charset' => $charset,
'encoding' => $encoding);
425 return $this->
_result(array(0 =>
'set subject'),
true);
429 function text($content = null, $charset = null, $encoding = null, $debug = null) {
432 if (!(is_string($content) && $content !=
'')) $err[] =
'invalid content type';
433 if ($charset != null) {
434 if (!is_string($charset)) $err[] =
'invalid charset type';
435 else if (!(strlen($charset) >= 2 &&
FUNC4::is_alpha($charset,
true,
'-'))) $err[] =
'invalid charset value';
437 if ($encoding != null) {
438 if (!is_string($encoding)) $err[] =
'invalid encoding type';
440 $encoding = strtolower($encoding);
441 if (!isset($this->_mime->mencarr[$encoding])) $err[] =
'invalid encoding value';
444 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
446 $this->Text = array(
'content' => $content,
'charset' => $charset,
'encoding' => $encoding);
447 return $this->
_result(array(0 =>
'set text version'),
true);
451 function html($content = null, $charset = null, $encoding = null, $debug = null) {
454 if (!(is_string($content) && $content !=
'')) $err[] =
'invalid content type';
455 if ($charset != null) {
456 if (!is_string($charset)) $err[] =
'invalid charset type';
457 else if (!(strlen($charset) >= 2 &&
FUNC4::is_alpha($charset,
true,
'-'))) $err[] =
'invalid charset value';
459 if ($encoding != null) {
460 if (!is_string($encoding)) $err[] =
'invalid encoding type';
462 $encoding = strtolower($encoding);
463 if (!isset($this->_mime->mencarr[$encoding])) $err[] =
'invalid encoding value';
466 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
468 $this->Html = array(
'content' => $content,
'charset' => $charset,
'encoding' => $encoding);
469 return $this->
_result(array(0 =>
'set html version'),
true);
473 function attach($content = null, $type = null, $name = null, $charset = null, $encoding = null, $disposition = null,
$id = null, $debug = null) {
476 if (!(is_string($content) && $content !=
'')) $err[] =
'invalid content type';
478 if (!is_string($type)) $err[] =
'invalid type value';
481 if (strlen($type) < 4) $err[] =
'invalid type value';
485 if (!is_string($name)) $err[] =
'invalid name type';
488 if ($name ==
'') $err[] =
'invalid name value';
491 if ($charset != null) {
492 if (!is_string($charset)) $err[] =
'invalid charset type';
493 else if (!(strlen($charset) >= 2 &&
FUNC4::is_alpha($charset,
true,
'-'))) $err[] =
'invalid charset value';
495 if ($encoding == null) $encoding =
'base64';
496 else if (is_string($encoding)) {
497 $encoding = strtolower($encoding);
498 if (!isset($this->_mime->mencarr[$encoding])) $err[] =
'invalid encoding value';
499 }
else $err[] =
'invalid encoding type';
500 if ($disposition == null) $disposition =
'attachment';
501 else if (is_string($disposition)) {
503 if (!($disposition ==
'inline' || $disposition ==
'attachment')) $err[] =
'invalid disposition value';
504 }
else $err[] =
'invalid disposition type';
506 if (!is_string(
$id)) $err[] =
'invalid id type';
509 if (
$id ==
'') $err[] =
'invalid id value';
512 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
514 $this->Attach[] = array(
'content' => $content,
'type' => $type,
'name' => $name,
'charset' => $charset,
'encoding' => $encoding,
'disposition' => $disposition,
'id' =>
$id);
515 return $this->
_result(array(0 =>
'add attachment'),
true);
522 $this->Attach = array();
523 return $this->
_result(array(0 =>
'delete all attachments'),
true);
524 }
else if (!(is_string($name) && strlen($name) > 1)) {
529 if (count($this->Attach) > 0) {
530 $name = strtolower($name);
531 foreach ($this->Attach as $att) {
532 if ($name == strtolower($att[
'name'])) $ret =
true;
537 $this->Attach = $new;
538 return $this->
_result(array(0 =>
'delete attachment'),
true);
539 }
else return FUNC4::trace($debug,
'attachment not found', 1);
543 function connect($host = null, $port = null, $user = null, $pass = null, $vssl = null, $tout = null, $name = null, $context = null, $auth = null, $debug = null) {
556 if ($ret =
SMTP4::connect($host, $port, $user, $pass, $vssl, $tout, $name, $context, $auth, $debug)) $this->_conns[] = $ret;
557 return $this->
_result($_RESULT, $ret);
565 if (count($this->_conns) > 0) {
567 foreach ($this->_conns as $cres) {
568 if ($cres != $resc) $new[] = $cres;
570 $this->_conns = $new;
573 return $this->
_result($_RESULT, $disc);
577 if (count($this->_conns) > 0) {
578 foreach ($this->_conns as $cres) {
583 return $this->
_result($rarr, $disc);
587 function send($resc = null, $debug = null) {
589 $_RESULT = $err = array();
591 if (is_resource($resc)) $delivery =
'relay';
593 if ($resc == null) $resc =
'local';
594 if (!is_string($resc)) $err[] =
'invalid connection type';
596 $resc = strtolower(trim($resc));
597 if ($resc ==
'local' || $resc ==
'client' || $resc ==
'sendmail' || $resc ==
'qmail') $delivery = $resc;
598 else $err[] =
'invalid connection value';
601 if (count($this->To) == 0) $err[] =
'to mail address is not set';
602 if (!isset($this->Subject[
'content'])) $err[] =
'mail subject is not set';
603 if (!(isset($this->Text[
'content']) || isset($this->Html[
'content']))) $err[] =
'mail message is not set';
604 if (count($err) > 0)
FUNC4::trace($debug, implode(
', ', $err));
606 $header[
'local'] = $header[
'client'] = array();
609 if (isset($this->From[
'address']) && is_string($this->From[
'address'])) {
610 $from = $this->From[
'address'];
612 if (isset($this->From[
'name']) && trim($this->From[
'name']) !=
'') {
614 isset($this->From[
'charset']) ? $this->From[
'charset'] : null,
615 isset($this->From[
'encoding']) ? $this->From[
'encoding'] : null,
617 if ($hn == $this->From[
'name']) $hn =
'"'.str_replace(
'"',
'\\"', $this->From[
'name']).
'"';
618 $hv .= $hn.
' <'.$this->From[
'address'].
'>';
619 }
else $hv .= $this->From[
'address'];
620 $header[
'local'][] = $hv;
621 $header[
'client'][] = $hv;
623 $addrs = $arr = array();
624 foreach ($this->To as
$to) {
625 if (isset($to[
'address']) &&
FUNC4::is_mail($to[
'address'],
false, $debug)) {
626 $addrs[] = $to[
'address'];
627 if (isset($to[
'name']) && trim($to[
'name']) !=
'') {
629 isset($to[
'charset']) ? $to[
'charset'] : null,
630 isset($to[
'encoding']) ? $to[
'encoding'] : null,
632 if ($hn == $to[
'name']) $hn =
'"'.str_replace(
'"',
'\\"', $to[
'name']).
'"';
633 $arr[] = $hn.
' <'.$to[
'address'].
'>';
634 }
else $arr[] = $to[
'address'];
637 if (count($arr) > 0) {
638 $to = implode(
', ', $arr);
639 $header[
'client'][] =
'To: '.implode(
', '.$this->_mime->LE.
"\t", $arr);
640 }
else FUNC4::trace($debug,
'to mail address is not set');
641 if (count($this->Cc) > 0) {
643 foreach ($this->Cc as $cc) {
644 if (isset($cc[
'address']) &&
FUNC4::is_mail($cc[
'address'],
false, $debug)) {
645 $addrs[] = $cc[
'address'];
646 if (isset($cc[
'name']) && trim($cc[
'name']) !=
'') {
648 isset($cc[
'charset']) ? $cc[
'charset'] : null,
649 isset($cc[
'encoding']) ? $cc[
'encoding'] : null,
651 if ($hn == $cc[
'name']) $hn =
'"'.str_replace(
'"',
'\\"', $cc[
'name']).
'"';
652 $arr[] = $hn.
' <'.$cc[
'address'].
'>';
653 }
else $arr[] = $cc[
'address'];
656 if (count($arr) > 0) {
657 $header[
'local'][] =
'Cc: '.implode(
', ', $arr);
658 $header[
'client'][] =
'Cc: '.implode(
', '.$this->_mime->LE.
"\t", $arr);
662 if (count($this->Bcc) > 0) {
664 foreach ($this->Bcc as $bcc) {
670 if (count($arr) > 0) {
671 $header[
'local'][] =
'Bcc: '.implode(
', ', $arr);
672 $hbcc = $this->_mime->LE.
'Bcc: '.implode(
', ', $arr);
676 isset($this->Subject[
'charset']) ? $this->Subject[
'charset'] : null,
677 isset($this->Subject[
'encoding']) ? $this->Subject[
'encoding'] : null,
680 $header[
'client'][] =
'Subject: '.$hn;
681 if (is_int($this->Priority) || is_string($this->Priority)) {
683 if ($this->Priority == 1 || $this->Priority ==
'high') $arr = array(1,
'high');
684 else if ($this->Priority == 3 || $this->Priority ==
'normal') $arr = array(3,
'normal');
685 else if ($this->Priority == 5 || $this->Priority ==
'low') $arr = array(5,
'low');
687 $header[
'local'][] =
'X-Priority: '.$arr[0];
688 $header[
'local'][] =
'X-MSMail-Priority: '.$arr[1];
689 $header[
'local'][] =
'X-MimeOLE: Produced By XPertMailer v.4 MIME Class';
690 $header[
'client'][] =
'X-Priority: '.$arr[0];
691 $header[
'client'][] =
'X-MSMail-Priority: '.$arr[1];
692 $header[
'client'][] =
'X-MimeOLE: Produced By XPertMailer v.4 MIME Class';
695 $header[
'client'][] =
'Message-ID: <'.MIME4::unique().
'@xpertmailer.com>';
696 if (count($this->Header) > 0) {
697 foreach ($this->Header as $harr) {
698 if (isset($harr[
'name'], $harr[
'value']) && strlen($harr[
'name']) >= 2 &&
FUNC4::is_alpha($harr[
'name'],
true,
'-')) {
700 isset($harr[
'charset']) ? $harr[
'charset'] : null,
701 isset($harr[
'encoding']) ? $harr[
'encoding'] : null,
703 $header[
'local'][] = ucfirst($harr[
'name']).
': '.$hn;
704 $header[
'client'][] = ucfirst($harr[
'name']).
': '.$hn;
709 if (isset($this->Text[
'content'])) {
711 isset($this->Text[
'charset']) ? $this->Text[
'charset'] : null,
712 isset($this->Text[
'encoding']) ? $this->Text[
'encoding'] : null,
713 null, null, null, null, $debug);
715 if (isset($this->Html[
'content'])) {
717 isset($this->Html[
'charset']) ? $this->Html[
'charset'] : null,
718 isset($this->Html[
'encoding']) ? $this->Html[
'encoding'] : null,
719 null, null, null, null, $debug);
721 if (count($this->Attach) > 0) {
723 foreach ($this->Attach as $attach) {
724 if (isset($attach[
'content'])) {
726 isset($attach[
'type']) ? $attach[
'type'] : null,
727 isset($attach[
'name']) ? $attach[
'name'] : null,
728 isset($attach[
'charset']) ? $attach[
'charset'] : null,
729 isset($attach[
'encoding']) ? $attach[
'encoding'] : null,
730 isset($attach[
'disposition']) ? $attach[
'disposition'] : null,
731 isset($attach[
'id']) ? $attach[
'id'] : null,
735 if (count($att) == 0) $att = null;
738 if ($delivery ==
'relay') {
739 $res =
SMTP4::send($resc, $addrs, implode($this->_mime->LE, $header[
'client']).$this->_mime->LE.$arr[
'header'].$this->_mime->LE.$this->_mime->LE.$arr[
'content'], (($this->Path != null) ? $this->Path :
$from), $debug);
740 return $this->
_result($_RESULT, $res);
741 }
else if ($delivery ==
'local') {
742 $rpath = (!
FUNC4::is_win() && $this->Path != null) ?
'-f '.$this->Path : null;
743 $spath = ($this->Path != null) ? @ini_set(
'sendmail_from', $this->Path) :
false;
744 if (!
FUNC4::is_win()) $arr[
'content'] = str_replace(
"\r\n",
"\n", $arr[
'content']);
745 $res = mail($to, $subject, $arr[
'content'], implode($this->_mime->LE, $header[
'local']).$this->_mime->LE.$arr[
'header'], $rpath);
746 if ($spath) @ini_restore(
'sendmail_from');
747 return $this->
_result(array(0 =>
'send mail local'), $res);
748 }
else if ($delivery ==
'client') {
750 foreach ($addrs as $addr) {
751 $exp = explode(
'@', $addr);
752 $group[strtolower($exp[1])][] = $addr;
755 $reg = (count($group) == 1);
756 foreach ($group as $domain => $arrs) {
757 $con =
SMTP4::mxconnect($domain, $this->Port, $this->Tout, $this->Name, $this->Context, $debug);
758 if ($reg) $this->
_result(array($domain => $_RESULT));
760 if (!
SMTP4::send($con, $arrs, implode($this->_mime->LE, $header[
'client']).$this->_mime->LE.$arr[
'header'].$this->_mime->LE.$this->_mime->LE.$arr[
'content'], (($this->Path != null) ? $this->Path :
$from), $debug)) $ret =
false;
761 if ($reg) $this->
_result(array($domain => $_RESULT));
765 if (!$reg) $this->
_result(array(0 =>
'send mail client'));
767 }
else if ($delivery ==
'sendmail' || $delivery ==
'qmail') {
769 $comm = (($delivery ==
'sendmail') ? $this->SendMail : $this->QMail).
' -oi'.(($this->Path != null) ?
' -f '.$this->Path :
'').
' -t';
770 if ($con = popen($comm,
'w')) {
771 if (fputs($con, implode($this->_mime->LE, $header[
'client']).$hbcc.$this->_mime->LE.$arr[
'header'].$this->_mime->LE.$this->_mime->LE.$arr[
'content'])) {
772 $res = pclose($con) >> 8 & 0xFF;
775 $this->
_result(array(0 =>
'send mail using "'.ucfirst($delivery).
'" program'));
776 }
else $this->
_result(array(0 => $res));
777 }
else $this->
_result(array(0 =>
'can not write'));
778 }
else $this->
_result(array(0 =>
'can not write line command'));