用php的类发送邮件有主题却没有类容?
好像是小露珠写的那个类。发送的邮件有主题有内容。但收到的只有主题没有内容。
请教。
这个是发送邮件类:
<?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>\r\n";
}
}
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."\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 = new smtp_mail("smtp.126.com","25","wildlily980","*******");
$smtp->send("wildlily980@126.com","wildlily980@126.com","你好","你好吗");
问题点数:50、回复次数:7Top
1 楼wildlily980(小李)回复于 2005-04-02 12:34:00 得分 0
upTop
2 楼zhiin(┈ Jcan ┈)回复于 2005-04-02 23:45:42 得分 25
我的也是
而且速度很慢 有时收不到 :-(
帮你顶!Top
3 楼wildlily980(小李)回复于 2005-04-03 00:45:33 得分 0
速度跟邮件服务商有关。我用126很快,用163很慢Top
4 楼wildlily980(小李)回复于 2005-04-05 10:18:27 得分 0
加到50分。Top
5 楼pinson(pinson)回复于 2005-04-05 14:03:36 得分 25
可能和SMTP服务器有关吧?Top
6 楼wildlily980(小李)回复于 2005-04-05 16:14:51 得分 0
126和163都不行,应该不是服务器的问题。Top
7 楼wildlily980(小李)回复于 2005-04-14 18:50:28 得分 0
难道没有人知道?Top
相关问题
- 用Outlook 2000发送邮件,邮件主题被截短!!!
- 用jmail发送邮件,邮件主题会出现乱码?!
- 谁有用 PHP 实现POP3收邮件功能的代码?我正在写一个类。出了点小问题
- 关于邮件的主题的问题,高手们请进来
- "girl" <girl@yahoo.com> 主题为~厨厨~ 是病毒邮件吗?
- ShellExecute怎样实现带主题发邮件?
- <a href=mailto:name@host.com?subject="主题"&body="内容">发邮件</a>
- <a href=mailto:name@host.com?subject="主题"&body="内容">发邮件</a>
- Indy的控件IdMessage组件的邮件主题的问题?
- 发送邮件链接怎么自动加上主题?




