Definition at line 54 of file smtp.inc.
◆ Authenticate()
SMTP::Authenticate |
( |
|
$username, |
|
|
|
$password |
|
) |
| |
Definition at line 980 of file smtp.inc.
982 fputs($this->smtp_conn,
"AUTH LOGIN" . $this->CRLF);
985 $code = substr($rply,0,3);
989 array(
"error" =>
"AUTH not accepted from server",
990 "smtp_code" =>
$code,
991 "smtp_msg" => substr($rply,4));
992 if($this->do_debug >= 1) {
993 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
1000 fputs($this->smtp_conn, base64_encode(
$username) . $this->CRLF);
1003 $code = substr($rply,0,3);
1007 array(
"error" =>
"Username not accepted from server",
1008 "smtp_code" =>
$code,
1009 "smtp_msg" => substr($rply,4));
1010 if($this->do_debug >= 1) {
1011 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
1018 fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
1021 $code = substr($rply,0,3);
1025 array(
"error" =>
"Password not accepted from server",
1026 "smtp_code" =>
$code,
1027 "smtp_msg" => substr($rply,4));
1028 if($this->do_debug >= 1) {
1029 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ Close()
Definition at line 179 of file smtp.inc.
180 $this->error =
null; # so there is no confusion
181 $this->helo_rply =
null;
182 if(!empty($this->smtp_conn)) {
183 # close the connection and cleanup
184 fclose($this->smtp_conn);
185 $this->smtp_conn = 0;
◆ Connect()
SMTP::Connect |
( |
|
$host, |
|
|
|
$port = 0 , |
|
|
|
$tval = 30 |
|
) |
| |
Definition at line 94 of file smtp.inc.
95 # set the error val to null so there is no confusion
98 # make sure we are __not__ connected
99 if($this->connected()) {
100 # ok we are connected! what should we do?
101 # for now we will just give an error saying we
102 # are already connected
104 array(
"error" =>
"Already connected to a server");
112 #connect to the smtp server
113 $this->smtp_conn = fsockopen($host, # the host of the server
114 $port, # the port
to use
115 $errno, # error number
if any
116 $errstr, # error
message if any
117 $tval); # give up after ? secs
118 # verify we connected properly
119 if(empty($this->smtp_conn)) {
120 $this->error = array(
"error" =>
"Failed to connect to server",
122 "errstr" => $errstr);
123 if($this->do_debug >= 1) {
124 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
130 # sometimes the SMTP server takes a little longer to respond
131 # so we will give it a longer timeout for the first read
132 # I have a report that on Windows systems this doesn't
134 #socket_set_timeout($this->smtp_conn, 1, 0);
136 # get any announcement stuff
139 # set the timeout of any socket functions at 1/10 of a second
140 #socket_set_timeout($this->smtp_conn, 0, 100000);
142 if($this->do_debug >= 2) {
143 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $announce;
◆ Connected()
Definition at line 154 of file smtp.inc.
155 if(!empty($this->smtp_conn)) {
156 $sock_status = socket_get_status($this->smtp_conn);
157 if($sock_status[
"eof"]) {
158 # hmm this is an odd situation... the socket is
159 # valid but we aren't connected anymore
160 if($this->do_debug >= 1) {
161 echo
"SMTP -> NOTICE:" . $this->CRLF .
162 "EOF caught while checking if connected";
167 return true; # everything looks good
◆ Data()
Definition at line 213 of file smtp.inc.
214 $this->error =
null; # so no confusion is caused
216 if(!$this->connected()) {
217 $this->error = array(
218 "error" =>
"Called Data() without being connected");
222 fputs($this->smtp_conn,
"DATA" . $this->CRLF);
225 $code = substr($rply,0,3);
227 if($this->do_debug >= 2) {
228 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
233 array(
"error" =>
"DATA command not accepted from server",
234 "smtp_code" =>
$code,
235 "smtp_msg" => substr($rply,4));
236 if($this->do_debug >= 1) {
237 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
243 # the server is ready to accept data!
244 # according to rfc 821 we should not send more than 1000
246 # characters on a single line so we will break the data up
247 # into lines by \r and/or \n then if needed we will break
248 # each of those into smaller lines to fit within the limit.
249 # in addition we will be looking for lines that start with
250 # a period '.' and append and additional period '.' to that
251 # line. NOTE: this does not count towards are limit.
253 # normalize the line breaks so we know the explode works
254 $msg_data = str_replace(
"\r\n",
"\n",$msg_data);
255 $msg_data = str_replace(
"\r",
"\n",$msg_data);
256 $lines = explode(
"\n",$msg_data);
258 # we need to find a good way to determine is headers are
259 # in the msg_data or if it is a straight msg body
260 # currently I'm assuming rfc 822 definitions of msg headers
261 # and if the first field of the first line (':' sperated)
262 # does not contain a space then it _should_ be a header
263 # and we can process all lines before a blank "" line as
265 $field = substr($lines[0],0,strpos($lines[0],
":"));
271 $max_line_length = 980; # used below;
set here
for ease in change
273 while(list(,$line) = @each($lines)) {
275 if($line ==
"" && $in_headers) {
278 # ok we need to break this line up into several
280 while(strlen($line) > $max_line_length) {
281 $pos = strrpos(substr($line,0,$max_line_length),
" ");
283 $pos = $max_line_length;
285 $lines_out[] = substr($line,0,$pos);
286 $line = substr($line,$pos + 1);
287 # if we are processing headers we need to
288 # add a LWSP-char to the front of the new line
289 # rfc 822 on long msg headers
291 $line =
"\t" . $line;
294 $lines_out[] = $line;
296 # now send the lines to the server
297 while(list(,$line_out) = @each($lines_out)) {
298 if(!empty($line_out) && $line_out[0] ==
".") {
299 $line_out =
"." . $line_out;
301 fputs($this->smtp_conn,$line_out . $this->CRLF);
305 # ok all the message data has been sent so lets get this
307 fputs($this->smtp_conn, $this->CRLF .
"." . $this->CRLF);
310 $code = substr($rply,0,3);
312 if($this->do_debug >= 2) {
313 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
318 array(
"error" =>
"DATA not accepted from server",
319 "smtp_code" =>
$code,
320 "smtp_msg" => substr($rply,4));
321 if($this->do_debug >= 1) {
322 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ Expand()
Definition at line 346 of file smtp.inc.
347 $this->error =
null; # so no confusion is caused
349 if(!$this->connected()) {
350 $this->error = array(
351 "error" =>
"Called Expand() without being connected");
355 fputs($this->smtp_conn,
"EXPN " .
$name . $this->CRLF);
358 $code = substr($rply,0,3);
360 if($this->do_debug >= 2) {
361 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
366 array(
"error" =>
"EXPN not accepted from server",
367 "smtp_code" =>
$code,
368 "smtp_msg" => substr($rply,4));
369 if($this->do_debug >= 1) {
370 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
376 # parse the reply and place in our array to return to user
377 $entries = explode($this->CRLF,$rply);
378 while(list(,$l) = @each($entries)) {
379 $list[] = substr($l,4);
◆ get_lines()
Definition at line 947 of file smtp.inc.
949 while($str = fgets($this->smtp_conn,515)) {
950 if($this->do_debug >= 4) {
951 echo
"SMTP -> get_lines(): \$data was \"$data\"" .
953 echo
"SMTP -> get_lines(): \$str is \"$str\"" .
957 if($this->do_debug >= 4) {
958 echo
"SMTP -> get_lines(): \$data is \"$data\"" .
$this->CRLF;
960 # if the 4th character is a space then we are done reading
961 # so just break the loop
962 if(substr($str,3,1) ==
" ") {
break; }
◆ Hello()
SMTP::Hello |
( |
|
$host = "" | ) |
|
Definition at line 397 of file smtp.inc.
398 $this->error =
null; # so no confusion is caused
400 if(!$this->connected()) {
401 $this->error = array(
402 "error" =>
"Called Hello() without being connected");
406 # if a hostname for the HELO wasn't specified determine
407 # a suitable one to send
409 # we need to determine some sort of appopiate default
410 # to send to the server
414 fputs($this->smtp_conn,
"HELO " . $host . $this->CRLF);
417 $code = substr($rply,0,3);
419 if($this->do_debug >= 2) {
420 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
425 array(
"error" =>
"HELO not accepted from server",
426 "smtp_code" =>
$code,
427 "smtp_msg" => substr($rply,4));
428 if($this->do_debug >= 1) {
429 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
435 $this->helo_rply = $rply;
◆ Help()
SMTP::Help |
( |
|
$keyword = "" | ) |
|
Definition at line 455 of file smtp.inc.
456 $this->error =
null; #
to avoid confusion
458 if(!$this->connected()) {
459 $this->error = array(
460 "error" =>
"Called Help() without being connected");
469 fputs($this->smtp_conn,
"HELP" . $extra . $this->CRLF);
472 $code = substr($rply,0,3);
474 if($this->do_debug >= 2) {
475 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
480 array(
"error" =>
"HELP not accepted from server",
481 "smtp_code" =>
$code,
482 "smtp_msg" => substr($rply,4));
483 if($this->do_debug >= 1) {
484 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ Mail()
Definition at line 507 of file smtp.inc.
508 $this->error =
null; # so no confusion is caused
510 if(!$this->connected()) {
511 $this->error = array(
512 "error" =>
"Called Mail() without being connected");
516 fputs($this->smtp_conn,
"MAIL FROM:" .
$from . $this->CRLF);
519 $code = substr($rply,0,3);
521 if($this->do_debug >= 2) {
522 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
527 array(
"error" =>
"MAIL not accepted from server",
528 "smtp_code" =>
$code,
529 "smtp_msg" => substr($rply,4));
530 if($this->do_debug >= 1) {
531 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ Noop()
Definition at line 549 of file smtp.inc.
550 $this->error =
null; # so no confusion is caused
552 if(!$this->connected()) {
553 $this->error = array(
554 "error" =>
"Called Noop() without being connected");
558 fputs($this->smtp_conn,
"NOOP" . $this->CRLF);
561 $code = substr($rply,0,3);
563 if($this->do_debug >= 2) {
564 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
569 array(
"error" =>
"NOOP not accepted from server",
570 "smtp_code" =>
$code,
571 "smtp_msg" => substr($rply,4));
572 if($this->do_debug >= 1) {
573 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ Quit()
SMTP::Quit |
( |
|
$close_on_error = true | ) |
|
Definition at line 592 of file smtp.inc.
593 $this->error =
null; # so there is no confusion
595 if(!$this->connected()) {
596 $this->error = array(
597 "error" =>
"Called Quit() without being connected");
601 # send the quit command to the server
602 fputs($this->smtp_conn,
"quit" . $this->CRLF);
604 # get any good-bye messages
607 if($this->do_debug >= 2) {
608 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
614 $code = substr($byemsg,0,3);
616 # use e as a tmp var cause Close will overwrite $this->error
617 $e = array(
"error" =>
"SMTP server rejected quit command",
618 "smtp_code" =>
$code,
619 "smtp_rply" => substr($byemsg,4));
621 if($this->do_debug >= 1) {
622 echo
"SMTP -> ERROR: " . $e[
"error"] .
": " .
627 if(empty($e) || $close_on_error) {
◆ Recipient()
Definition at line 646 of file smtp.inc.
647 $this->error =
null; # so no confusion is caused
649 if(!$this->connected()) {
650 $this->error = array(
651 "error" =>
"Called Recipient() without being connected");
655 fputs($this->smtp_conn,
"RCPT TO:" .
$to . $this->CRLF);
658 $code = substr($rply,0,3);
660 if($this->do_debug >= 2) {
661 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
666 array(
"error" =>
"RCPT not accepted from server",
667 "smtp_code" =>
$code,
668 "smtp_msg" => substr($rply,4));
669 if($this->do_debug >= 1) {
670 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ Reset()
Definition at line 690 of file smtp.inc.
691 $this->error =
null; # so no confusion is caused
693 if(!$this->connected()) {
694 $this->error = array(
695 "error" =>
"Called Reset() without being connected");
699 fputs($this->smtp_conn,
"RSET" . $this->CRLF);
702 $code = substr($rply,0,3);
704 if($this->do_debug >= 2) {
705 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
710 array(
"error" =>
"RSET failed",
711 "smtp_code" =>
$code,
712 "smtp_msg" => substr($rply,4));
713 if($this->do_debug >= 1) {
714 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ Send()
Definition at line 739 of file smtp.inc.
740 $this->error =
null; # so no confusion is caused
742 if(!$this->connected()) {
743 $this->error = array(
744 "error" =>
"Called Send() without being connected");
748 fputs($this->smtp_conn,
"SEND FROM:" .
$from . $this->CRLF);
751 $code = substr($rply,0,3);
753 if($this->do_debug >= 2) {
754 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
759 array(
"error" =>
"SEND not accepted from server",
760 "smtp_code" =>
$code,
761 "smtp_msg" => substr($rply,4));
762 if($this->do_debug >= 1) {
763 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ SendAndMail()
SMTP::SendAndMail |
( |
|
$from | ) |
|
Definition at line 787 of file smtp.inc.
788 $this->error =
null; # so no confusion is caused
790 if(!$this->connected()) {
791 $this->error = array(
792 "error" =>
"Called SendAndMail() without being connected");
796 fputs($this->smtp_conn,
"SAML FROM:" .
$from . $this->CRLF);
799 $code = substr($rply,0,3);
801 if($this->do_debug >= 2) {
802 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
807 array(
"error" =>
"SAML not accepted from server",
808 "smtp_code" =>
$code,
809 "smtp_msg" => substr($rply,4));
810 if($this->do_debug >= 1) {
811 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ SendOrMail()
SMTP::SendOrMail |
( |
|
$from | ) |
|
Definition at line 835 of file smtp.inc.
836 $this->error =
null; # so no confusion is caused
838 if(!$this->connected()) {
839 $this->error = array(
840 "error" =>
"Called SendOrMail() without being connected");
844 fputs($this->smtp_conn,
"SOML FROM:" .
$from . $this->CRLF);
847 $code = substr($rply,0,3);
849 if($this->do_debug >= 2) {
850 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
855 array(
"error" =>
"SOML not accepted from server",
856 "smtp_code" =>
$code,
857 "smtp_msg" => substr($rply,4));
858 if($this->do_debug >= 1) {
859 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ SMTP()
Definition at line 69 of file smtp.inc.
72 $this->helo_rply =
null;
◆ Turn()
Definition at line 880 of file smtp.inc.
881 $this->error = array(
"error" =>
"This method, TURN, of the SMTP ".
882 "is not implemented");
883 if($this->do_debug >= 1) {
884 echo
"SMTP -> NOTICE: " . $this->error[
"error"] .
$this->CRLF;
◆ Verify()
Definition at line 902 of file smtp.inc.
903 $this->error =
null; # so no confusion is caused
905 if(!$this->connected()) {
906 $this->error = array(
907 "error" =>
"Called Verify() without being connected");
911 fputs($this->smtp_conn,
"VRFY " .
$name . $this->CRLF);
914 $code = substr($rply,0,3);
916 if($this->do_debug >= 2) {
917 echo
"SMTP -> FROM SERVER:" . $this->CRLF . $rply;
922 array(
"error" =>
"VRFY failed on name '$name'",
923 "smtp_code" =>
$code,
924 "smtp_msg" => substr($rply,4));
925 if($this->do_debug >= 1) {
926 echo
"SMTP -> ERROR: " . $this->error[
"error"] .
◆ $CRLF
◆ $do_debug
◆ $error
◆ $helo_rply
◆ $smtp_conn
◆ $SMTP_PORT
The documentation for this class was generated from the following file:
- C:/code/cms.sonjara.com/cms/components/email/smtp.inc