Sending emails using Socket 6_PHP Tutorial

WBOY
Release: 2016-07-13 17:28:05
Original
1427 people have browsed it

Execute a command
1 function do_command($command, $code)
2 {
3 $this-$#@62; lastact=$command;
4 $this-$#@62; show_debug($this-$#@62;lalastact, "out");
5 fputs ( $this-$#@62;fp, $this-$#@62;lastat );
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 {
10 return false;
11 }
12 else
13 return true;
14 }
When writing the socket processing part, I found that the processing of some commands is very similar, such as HELO, MAIL FROM, RCPT TO, QUIT, and DATA commands, all of which require whether to display debugging information. Display the relevant content, and at the same time, if the returned response code is expected, the processing should continue. If it is not expected, the processing should be interrupted. Therefore, for the sake of clarity and simplification, a general processing function is specially written for processing these commands.
Among the parameters of the function, $code is the expected response code. If the response code is the same, it means the processing is successful, otherwise an error occurs.
Line 3 records the last executed command.
Line 4 displays the upload command.
Line 5 uses fputs to actually transfer instructions to the server.
Line 6, the response information received from the server will be placed in the last response message variable.
Line 7 displays the response information.
Line 8 determines whether the response information is expected. If so, line 13 returns success (true), otherwise line 10 returns failure (false).
In this way, on the one hand, this function completes the function of sending and displaying instructions and information, and on the other hand, it judges whether the returned response is successful.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531798.htmlTechArticleExecute 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-...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!