php Socket发送电子邮箱来验证邮箱的真实有效性而非格式
May 25, 2016 pm 05:15 PM
php
socket
hantar
keberkesanan
E-mel
realiti
Mengesahkan E-mel
验证邮箱的真实性而非格式
<?php set_time_limit(120); class smtp_mail { var $host; //主机 var $port; //端口 一般为25 var $user; //SMTP认证的帐号 var $pass; //认证密码 var $debug = false; //是否显示和服务器会话信息? var $conn; var $result_str; //结果 var $in; //客户机发送的命令 var $from; //源信箱 var $to; //目标信箱 var $subject; //主题 var $body; //内容 function smtp_mail($host,$port,$user,$pass,$debug=false) { $this->host = $host; $this->port = $port; $this->user = base64_encode($user); $this->pass = base64_encode($pass); $this->debug = $debug; $this->socket = socket_create (AF_INET, SOCK_STREAM, SOL_TCP); //具体用法请参考手册 if($this->socket) { $this->result_str ="创建SOCKET:".socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("初始化失败,请检查您的网络连接和参数"); } $this->conn = socket_connect($this->socket,$this->host,$this->port); if($this->conn) { $this->result_str ="创建SOCKET连接:".socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("初始化失败,请检查您的网络连接和参数"); } $this->result_str ="服务器应答:<font color=#cc0000>".socket_read ($this->socket, 1024)."</font>"; $this->debug_show($this->result_str); } function debug_show($str) { if($this->debug) { echo $str."<p>rn"; } } function send($from,$to,$subject,$body) { if($from ==""|| $to =="") { exit("请输入信箱地址"); } if($subject =="") $sebject ="无标题"; if($body =="") $body ="无内容"; $this->from = $from; $this->to = $to; $this->subject = $subject; $this->body = $body; //扬帆修改部分代码 $All ="From:<".$this->from.">rn"; $All .="To:<".$this->to.">rn"; $All .="Subject:".$this->subject."rnrn"; $All .= $this->body; //以下是和服务器会话 $this->in ="EHLO HELOrn"; $this->docommand(); $this->in ="AUTH LOGINrn"; $this->docommand(); $this->in = $this->user."rn"; $this->docommand(); $this->in = $this->pass."rn"; $this->docommand(); // $this->in ="MAIL FROM:".$this->from."rn"; $this->in ="MAIL FROM:<".$this->from.">rn"; //扬帆修改 $this->docommand(); // $this->in ="RCPT TO:".$this->to."rn"; $this->in ="RCPT TO:<".$this->to.">rn"; //扬帆修改 $this->docommand(); $this->in ="DATArn"; $this->docommand(); $this->in = $All."rn.rn"; $this->docommand(); $this->in ="QUITrn"; $this->docommand(); //结束,关闭连接 } function docommand() { socket_write ($this->socket, $this->in, strlen ($this->in)); $this->debug_show("客户机命令:".$this->in); $this->result_str ="服务器应答:<font color=#cc0000>".socket_read ($this->socket, 1024)."</font>"; $this->debug_show($this->result_str); } } ?>
Salin selepas log masuk
<?php //测试页面 include"smtp_mail.php"; //你用这个类的时候你修改成你自己的信箱就可以了 $smtp=new smtp_mail("smtp.qq.com","25","yourmail@qq.com","Your password",true); //如果你需要显示会话信息,请将上面的修改成 //$smtp = new smtp_mail("smtp.qq.com","25","你的qq.com的帐号","你的密码",true); $smtp->send("yourmail@qq.com","yourmail@qq.com","你好","测试邮件"); ?>
Salin selepas log masuk
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn

Artikel Panas
Berapa lama masa yang diperlukan untuk mengalahkan fiksyen berpecah?
3 minggu yang lalu
By DDD
Repo: Cara menghidupkan semula rakan sepasukan
3 minggu yang lalu
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: Cara mendapatkan biji gergasi
3 minggu yang lalu
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Kristal tenaga dijelaskan dan apa yang mereka lakukan (kristal kuning)
1 minggu yang lalu
By 尊渡假赌尊渡假赌尊渡假赌

Alat panas Tag

Artikel Panas
Berapa lama masa yang diperlukan untuk mengalahkan fiksyen berpecah?
3 minggu yang lalu
By DDD
Repo: Cara menghidupkan semula rakan sepasukan
3 minggu yang lalu
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: Cara mendapatkan biji gergasi
3 minggu yang lalu
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Kristal tenaga dijelaskan dan apa yang mereka lakukan (kristal kuning)
1 minggu yang lalu
By 尊渡假赌尊渡假赌尊渡假赌

Tag artikel panas

Notepad++7.3.1
Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina
Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1
Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6
Alat pembangunan web visual

SublimeText3 versi Mac
Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

Topik panas

Panduan Pemasangan dan Naik Taraf PHP 8.4 untuk Ubuntu dan Debian

Cara Menyediakan Kod Visual Studio (Kod VS) untuk Pembangunan PHP
