The previously seen PHP mail function, it is good or not bad.

zhaozj2021-02-08  295

For a real example Take a Look at: http://www.triple-it.nl/pop3/

I Have Just Started to Explore The World of PHP3, SO EXCUSE (and Correct Me :) if i'm doing something wrong.

UNK. (Rgroesb@triple-it.nl) * /

Function Pop3_open ($ Server, $ Port) {Global $ POP3_GLOBAL_STATUS

$ pop3 = fsockopen ($ Server, $ port); if ($ POP3 <= 0) Return 0;

$ line = fgets ($ POP3, 1024); $ pop3_global_status [$ pop3] ["LastResult"] = SUBSTR ($ Line, 0, 1); $ pop3_global_status [$ pop3] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024);

IF ($ POP3_GLOBAL_STATUS [$ POP3] ["LastResult"] <> " ") RETURN 0;

Return $ POP3;

Function Pop3_user ($ POP3, $ USER) {global $ pop3_global_status;

FPUTS ($ POP3, "User $ USER / R / N); $ line = fgets ($ POP3, 1024); $ pop3_global_status [$ pop3] [" LastResult "] = SUBSTR ($ Line, 0, 1); $ POP3_GLOBAL_STATUS [$ POP3] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024); IF ($ pop3_global_status [$ pop3] ["LastResult"] <> " ") Return 0;

Return 1;}

Function pop3_pass ($ POP3, $ Pass) {global $ pop3_global_status;

FPUTS ($ POP3, "Pass $ Pass / R / N); $ line = fgets ($ POP3, 1024); $ pop3_global_status [$ pop3] [" LastResult "] = Substr ($ Line, 0, 1); $ POP3_GLOBAL_STATUS [$ POP3] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024); IF ($ pop3_global_status [$ pop3] ["LastResult"] <> " ") Return 0;

Return 1;} Function Pop3_stat ($ pop3) {global $ pop3_global_status;

FPUTS ($ POP3, "STAT / R / N"); $ line = fgets ($ POP3, 1024); $ pop3_global_status [$ pop3] ["LastResult"] = Substr ($ Line, 0, 1); $ pop3_global_status [ $ POP3] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024); if ($ pop3_global_status [$ pop3] ["LastResult"] <> " ") Return 0;

IF (! EREGI (" OK (. *) (. *)", $ Line, $ regs) Return 0;

Return $ regs [1];

Function pop3_list ($ pop3) {global $ pop3_global_status; fputs ($ POP3, "List / R / N"); $ line = fgets ($ POP3, 1024); $ pop3_global_status [$ pop3] ["LastResult"] = SUBSTR $ Line, 0, 1); $ pop3_global_status [$ pop3] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024);

IF ($ POP3_GLOBAL_STATUS [$ POP3] ["LastResult"] <> " ") RETURN 0;

$ i = 0; while (substr ($ POP3, 1024), 0, 1) <> "") {$ Articles [$ I] = $ line; $ i ;} $ article ["count "] = $ i;

Return $ articles;

Function POP3_RETR ($ POP3, $ NR) {Global $ POP3_GLOBAL_STATUS; FPUTS ($ POP3, "RETR $ NR / R / N"); $ line = fgets ($ POP3, 1024); $ pop3_global_status [$ pop3] ["LastResult "] = SUBSTR ($ Line, 0, 1); $ pop3_global_status [$ pop3] [" LastResulttxt "] = SUBSTR ($ Line, 0, 1024);

IF ($ POP3_GLOBAL_STATUS [$ POP3] ["LastResult"] <> " ") RETURN 0;

While ($ line = fgets ($ POP3, 1024), 0, 1) <> "") {$ data [$ I] = $ line; $ i ;} $ data ["count"] = $ i ;

Return $ data;}

Function pop3_dele ($ POP3, $ NR) {global $ pop3_global_status; fputs ($ POP3, "DELE $ NR / R / N"); $ line = fgets ($ POP3, 1024); $ pop3_global_status [$ pop3] ["LastResult "] = SUBSTR ($ Line, 0, 1); $ pop3_global_status [$ pop3] [" LastResulttxt "] = SUBSTR ($ Line, 0, 1024);

IF ($ POP3_GLOBAL_STATUS [$ POP3] ["LastResult"] <> " ") RETURN 0;

Return 1;}

Function pop3_quit ($ pop3) {global $ pop3_global_status;

FPUTS ($ POP3, "QUIT / R / N"); $ line = fgets ($ POP3, 1024); $ pop3_global_status [$ pop3] ["LastResult"] = Substr ($ Line, 0, 1); $ pop3_global_status [ $ POP3] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024);

IF ($ POP3_GLOBAL_STATUS [$ POP3] ["LastResult"] <> " ") RETURN 0;

Return 1;}

Function SMTP_Open ($ Server, $ Port) {Global $ SMTP_GLOBAL_STATUS

$ SMTP = FSOCKOPEN ($ Server, $ Port); if ($ SMTP <0) Return 0;

$ line = fgets ($ SMTP, 1024); $ SMTP_GLOBAL_STATUS [$ SMTRESULT "] = SUBSTR ($ Line, 0, 1); $ SMTP_GLOBAL_STATUS [$ SMTP] [" LastResulttxt "] = SUBSTR ($ Line, 0, 1024);

IF ($ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] <> "2") Return 0;

Return $ SMTP;

Function SMTP_HELO ($ SMTP) {Global $ SMTP_GLOBAL_STATUS;

/ * 'localhost' always works [unk] * / fputs ($ SMTP, "Helo LocalHost / R / N"); $ LINE = FGETS ($ SMTP, 1024); $ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] = Substr ($ Line, 0, 1); $ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024);

IF ($ SMTP_GLOBAL_STATUS [$ SMTRESULT "] <>" 2 ") Return 0; Return 1;} Function SMTP_EHLO ($ SMTP) {Global $ SMTP_GLOBAL_STATUS;

/ * Well, Let's Use "Helo" for now.. Until We need The extra func's [unk] * / fputs ($ SMTP, "Helo LocalHost / R / N"); $ line = fgets ($ SMTP, 1024); $ SMTP_GLOBAL_STATUS [$ SMTRESULT "] = SUBSTR ($ Line, 0, 1); $ SMTP_GLOBAL_STATUS [$ SMTP] [" LastResulttxt "] = SUBSTR ($ Line, 0, 1024);

IF ($ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] <> "2") Return 0;

Return 1;}

Function SMTP_MAIL_FROM ($ SMTP, $ from) {Global $ SMTP_GLOBAL_STATUS

FPUTS ($ SMTP, "Mail from: <$ from> / r / n"); $ line = fgets ($ SMTP, 1024); $ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] = SUBSTR ($ Line, 0, 1); $ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024);

IF ($ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] <> "2") Return 0;

Return 1;} Function SMTP_RCPT_TO ($ SMTP, $ TO) {Global $ SMTP_GLOBAL_STATUS

FPUTS ($ SMTP, "RCPT TO: <$ TO> / R / N"); $ line = fgets ($ SMTP, 1024); $ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] = SUBSTR ($ Line, 0, 1); $ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024);

IF ($ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] <> "2") Return 0;

Return 1;}

Function SMTP_DATA ($ SMTP, $ SUBJECT, $ DATA) {Global $ SMTP_GLOBAL_STATUS

FPUTS ($ SMTP, "DATA / R / N"); $ LINE = FGETS ($ SMTP, 1024); $ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] = SUBSTR ($ Line, 0, 1); $ SMTP_GLOBAL_STATUS [ $ SMTP] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024); IF ($ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] <> "3") Return 0;

FPUTS ($ SMTP, "MIME-VERSION: 1.0 / R / N"); FPUTS ($ SMTP, "Subject: $ SUBJECT / R / N"); FPUTS ($ SMTP, "$ DATA / R / N / R / N "); FPUTS ($ SMTP," ./R/N "); $ line = fgets ($ SMTP, 1024); IF (Substr ($ Line, 0, 1) <>" 2 ") Return 0;

Return 1;} function smtp_quit ($ SMTP) {Global $ SMTP_GLOBAL_STATUS;

FPUTS ($ SMTP, "Quit / R / N"); $ line = fgets ($ SMTP, 1024); $ SMTP_GLOBAL_STATUS [$ SMTR] ["LastResult"] = SUBSTR ($ Line, 0, 1); $ SMTP_GLOBAL_STATUS [ $ SMTP] ["LastResulttxt"] = SUBSTR ($ Line, 0, 1024);

IF ($ SMTP_GLOBAL_STATUS [$ SMTP] ["LastResult"] <> "2") Return 0;

Return 1;}

/ * $ POP3 = POP3_Open ("localhost", "110"); if (! $ Pop3) {printf ("[error] failed to connect to localhost
/ n"); return 0;} if (! POP3_USER ($ POP3, "UNK")) {Printf ("[Error] UserName Failed!
/ n"); return 0;}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} ($ pop3, "secret")) {printf ("[Error" ] Pass failed!
/ n "); returnography;

转载请注明原文地址:https://www.9cbs.com/read-1783.html

New Post(0)