用Socket发送电子邮件六_PHP教程

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

执行一个命令
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 {
10 return false;
11 }
12 else
13 return true;
14 }
  在编写socket处理部分发现,一些命令的处理很相似,如HELO,MAIL FROM,RCPT TO,QUIT,DATA命令,都要求根据是否显示调试信息将相关内容显示出来,同时对于返回的响应码,如果是期望的,则应继续处理,如果不是期望的,则应中断出理。所以为了清晰与简化,专门对这些命令的处理编写了一个通用处理函数。
函数的参数中$code为期望的响应码,如果响应码与之相同则表示处理成功,否则出错。
第3行,记录最后执行命令。
第4行,将上传命令显示出来。
第5行,则使用fputs真正向服务器传换指令。
第6行,从服务器接收响应信息将放在最后响应消息变量中。
第7行,将响应信息显示出来。
第8行,判断响应信息是否期待的,如果是则第13行返回成功(true),否则在第10行返回失败(false)。
  这样,这个函数一方面完成指令及信息的发送显示功能,别一方面对返回的响应判断是否成功。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/531798.htmlTechArticle执行一个命令 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!