Server_name can use php own dns resolution function, the following is the core demo, winNT, mailserverisImail, php3.0.6 need to modify php3.ini open imap module, in linux to compile php -- with-IMAPSyntaxHighlighter.all ();
Server_name can use php's own dns resolution function,
The following is a core demonstration: winNT, mail server is Imail, php3.0.6
You need to modify php3.ini to open the imap module and compile php -- with-IMAP on linux.
Function send_email ($ to, $ from, $ subject, $ message ){
Global $ SERVER_NAME;
$ Fp = fsockopen ($ SERVER_NAME, 25 );
If ($ fp ){
Echo "connected ";
Set_socket_blocking ($ fp, false );
$ Output = fgets ($ fp, 2500 );
Echo $ output;
If (! Ereg ("^ 220", $ output )){
Exit ();
} Else {
Echo "talking ";
// Set_socket_blocking ($ fp, true );
Fputs ($ fp, "HELO $ from_domain ");
$ Output = fgets ($ fp, 2000 );
Echo $ output;
Fputs ($ fp, "mail from: <$ from> ");
$ Output = fgets ($ fp, 2000 );
Echo $ output;
Fputs ($ fp, "rcpt to: <$ to> ");
$ Output = fgets ($ fp, 2000 );
Echo $ output;
Fputs ($ fp, "DATA ");
Fputs ($ fp, "To: $ ");
Fputs ($ fp, "From: $ from ");
Fputs ($ fp, "Subject: $ subject ");
Fputs ($ fp, "$ message .");
Fputs ($ fp, "QUIT ");
}
}
Fclose ($ fp );
}
$ SERVER_NAME = "127.0.0.1 ";
$ From_domain = "ws ";
$ To = "daiger@xifeng.com ";
$ From = "wangsu@xifeng.com ";
$ Subject = "test SMTP through PHP Chinese ";
$ Message = "Send email via PHP smtp connectionsnnnothing happenesn Chinese
Chinese ";
Send_email ($ to, $ from, $ subject, $ message );
Echo "OK lah ";
?>