찾다
php教程PHP源码php Socket发送电子邮箱来验证邮箱的真实有效性而非格式

php Socket发送电子邮箱来验证邮箱的真实有效性而非格式

May 25, 2016 pm 05:15 PM
phpsocket보내다유효성이메일현실이메일 확인

验证邮箱的真实性而非格式

<?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);
}
}
?>
<?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","你好","测试邮件");
?>
성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
3 몇 주 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

SecList

SecList

SecLists는 최고의 보안 테스터의 동반자입니다. 보안 평가 시 자주 사용되는 다양한 유형의 목록을 한 곳에 모아 놓은 것입니다. SecLists는 보안 테스터에게 필요할 수 있는 모든 목록을 편리하게 제공하여 보안 테스트를 더욱 효율적이고 생산적으로 만드는 데 도움이 됩니다. 목록 유형에는 사용자 이름, 비밀번호, URL, 퍼징 페이로드, 민감한 데이터 패턴, 웹 셸 등이 포함됩니다. 테스터는 이 저장소를 새로운 테스트 시스템으로 간단히 가져올 수 있으며 필요한 모든 유형의 목록에 액세스할 수 있습니다.

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.