用Socket寄送電子郵件(七)_PHP教程

來源:互聯網
上載者:User
b>郵件發送處理
  下面是真正的秘密了,可要看仔細了。:)
1 function send( $to,$from,$subject,$message)
2 {
3 //串連伺服器
4 $this-$#@62;lastact="connect";
5 $this-$#@62;show_debug("Connect to SMTP server : ".$this-$#@62;smtp, "out");
6 $this-$#@62;fp = fsockopen ( $this-$#@62;smtp, $this-$#@62;port );
7 if ( $this-$#@62;fp )
8 {
9 set_socket_blocking( $this-$#@62;fp, true );
10 $this-$#@62;lastmessage=fgets($this-$#@62;fp,512);
11 $this-$#@62;show_debug($this-$#@62;lastmessage, "in");
12 if (! ereg ( "^220", $this-$#@62;lastmessage ) )
13 {
14 return false;
15 }
16 else
17 {
18 $this-$#@62;lastact="HELO " . $this-$#@62;welcome . "";
19 if(!$this-$#@62;do_command($this-$#@62;lastact, "250"))
20 {
21 fclose($this-$#@62;fp);
22 return false;
23 }
24 $this-$#@62;lastact="MAIL FROM: $from" . "";

25 if(!$this-$#@62;do_command($this-$#@62;lastact, "250"))
26 {
27 fclose($this-$#@62;fp);
28 return false;
29 }
30 $this-$#@62;lastact="RCPT TO: $to" . "";
31 if(!$this-$#@62;do_command($this-$#@62;lastact, "250"))
32 {
33 fclose($this-$#@62;fp);
34 return false;
35 }
36 //發送本文
37 $this-$#@62;lastact="DATA";
38 if(!$this-$#@62;do_command($this-$#@62;lastact, "354"))
39 {
40 fclose($this-$#@62;fp);
41 return false;
42 }
43 //處理Subject頭
44 $head="Subject: $subject";
45 if(!empty($subject) && !ereg($head, $message))
46 {
47 $message = $head.$message;
48 }
49 //處理From頭
50 $head="From: $from";
51 if(!empty($from) && !ereg($head, $message))
52 {
53 $message = $head.$message;
54 }
55 //處理To頭
56 $head="To: $to";
57 if(!empty($to) && !ereg($head, $message))
58 {
59 $message = $head.$message;
60 } <

http://www.bkjia.com/PHPjc/532378.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532378.htmlTechArticleb>郵件發送處理 下面是真正的秘密了,可要看仔細了。:) 1 function send( $to,$from,$subject,$message) 2 { 3 //串連伺服器 4 $this-$#@62;lastact="connect"; 5...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.