Socket を使用したメール送信 (7)_PHP チュートリアル

WBOY
リリース: 2016-07-13 17:21:54
オリジナル
809 人が閲覧しました

b> 送信処理
以下は真正の秘密です、可用です。:)
1 function send( $to,$from,$subject,$message)
2 {
3 //接続サーバー
4 $ this-$#@62;lastact="接続";
5 $this-$#@62;show_debug("SMTP サーバーに接続します : ".$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 他
17 {
18 $this-$#@62;lastact="HELO " . $this-$#@62;ようこそ。 」 ";
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 ";
45 if(!empty($subject) && !ereg($head, $message))
46 {
47 $message = $head.$message;
48 }
49 //处理From头
50 $ head="差出人: $from ";
51 if(!empty($from) && !ereg($head, $message))
52 {
53 $message = $head.$message;
54 }
55 //处理To头
56 $ head="宛先: $to ";
57 if(!empty($to) && !ereg($head, $message))
58 {
59 $message = $head.$message;
60 }

www.bkjia.com本当http://www.bkjia.com/PHPjc/532378.html技術記事 b> パッケージ送信処理 以下は真の秘密であり、参照できます。:) 1 function send( $to,$from,$subject,$message) 2 { 3 // サーバーを接続します 4 $this-$#@ 62;lastact="接続"; 5...
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!