Send an email using the socket six _php tutorial

Source: Internet
Author: User
Tags response code
Execute a command
1 function Do_command ($command, $code)
2 {
3 $this-$#@62;lastact= $command;
4 $this-$#@62;show_debug ($this-$#@62;lastact, "out");
5 fputs ($this-$#@62;fp, $this-$#@62;lastact);
6 $this-$#@62;lastmessage = fgets ($this-$#@62;FP, 512);
7 $this-$#@62;show_debug ($this-$#@62;lastmessage, "in");
8 if (!ereg ("^ $code", $this-$#@62;lastmessage))
9 {
Ten return false;
return true;
In the Socket Processing section, it is found that some commands are handled very similarly, such as the Helo,mail from,rcpt to,quit,data command, which requires that the relevant content be displayed based on whether the debug information is displayed, and that the response code returned, if desired, should continue processing, If it is not expected, the rationale should be interrupted. So for clarity and simplification, a generic handler is written specifically for the processing of these commands.
The function's parameters are $code to the desired response code, and if the response code is the same, the processing succeeds, otherwise an error occurs.
The 3rd Line records the final execution of the command.
Line 4th, display the upload command.
Line 5th, use fputs to actually transfer instructions to the server.
On line 6th, the response information received from the server is placed in the last response message variable.
The 7th line displays the response information.
Line 8th, determines whether the response information is expected, if it is the 13th row returns success (true), otherwise the 10th row returns failure (false).
This function, on the one hand, completes the sending and displaying function of the instruction and information, and does not determine the success of the returned response. true techarticle executes a command 1 function do_command ($command, $code) 2 {3 $this-$#@62;lastact= $command; 4 $this-$#@62;show_debug ($this-$#@ 62;lastact, "out"); 5 fputs ($this-$#@62;fp, $this-...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.