盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

用Socket发送电子邮件(使用需要验证的SMTP服务器)

时间:2024/11/26作者:未知来源:盾怪网教程人气:

[摘要]to == "") exit("请输入信箱地址"); if(subject == "") sebject = "无标题&qu...
$to == "")
{
exit("请输入信箱地址");
}
if($subject == "") $sebject = "无标题";
if($body    == "") $body    = "无内容";
$this->from     =  $from;
$this->to       =  $to;
$this->subject  =  $subject;
$this->body     =  $body;

$All          = "From:".$this->from."\n";
$All          .= "To:".$this->to."\n";
$All          .= "Subject:".$this->subject."\n";
$All          .= $this->body;
/*
  如过把$All的内容再加处理,就可以实现发送MIME邮件了
  不过还需要加很多程序
*/


//以下是和服务器会话
$this->in       =  "EHLO HELO\r\n";
$this->docommand();

$this->in       =  "AUTH LOGIN\r\n";
$this->docommand();

$this->in       =  $this->user."\r\n";
$this->docommand();

$this->in       =  $this->pass."\r\n";
$this->docommand();

$this->in       =  "MAIL FROM:".$this->from."\r\n";
$this->docommand();

$this->in       =  "RCPT TO:".$this->to."\r\n";
$this->docommand();

$this->in       =  "DATA\r\n";
$this->docommand();

$this->in       =  $All."\r\n.\r\n";
$this->docommand();

$this->in       =  "QUIT\r\n";
$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);
}
}
//这个是我做的测试,我用的是smtp.163.com,那你的信箱也必须是163.com的,要不人家不让你发!!
//你用这个类的时候你修改成你自己的信箱就可以了
$smtp  =   new smtp_mail("smtp.163.com","25","你的163.com的帐号","你的密码");
//如果你需要显示会话信息,请将上面的修改成
//$smtp  =   new smtp_mail("smtp.163.com","25","你的163.com的帐号","你的密码",true);
$smtp->send("你的163.com的帐号@163.com","目标地址","你好","你好");
?>



关键词:用Socket发送电子邮件(运用需要验证的SMTP服务器)




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版