The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine). Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by the MTA in the first place, but are parsed by PHP. PHP < 4.3 only supported the Cc: header element (and was case-sensitive). PHP >= 4.3 supports all the mentioned header elements and is no longer case-sensitive.
解决方案 »
- php中使用svn_checkout
- apache php mysql套件
- 怎么用 php 开发blog后生成 rss 文件?
- 求解mysql的com_select状态?
- 请问各位,有谁知道在php中有从 TextStream 文件中读入指定数目的字符并返回结果字符串的函数?
- 100分,求如何按每个月统计注册会员数
- print "<tr><td width=100% bgcolor=$abc>fyx maggie</td></tr>";
- mail函数的应用
- 请问如何安装GD图形库呀
- trim去特殊空格的问题
- 散分了,开始学php了
- 怎样用adodb这套组件不用limit 10,40之类的sql语句来达到分页的目的?以及,如何象在asp里面调用ado这种com对象的时候设置CursorType和Lo
说明socket_create()函数被禁了
先谢谢你!
我没做什么别的操作啊,怎么会出现这种情况
要怎么改好啊.
还有那个mail函数为什么也不行了
2、Fatal error: Call to undefined function: socket_create() in c:\apache\htdocs\mail\nm.php on line 45
你没有连接socket扩展库
function send22($to,$from,$subject, $message )
{
$to="[email protected]";
$from="[email protected]";
$subject="test";
$message="test";
//使用本函数之前,务必请定义好以下变量
#############################################$smtp ="smtp.eyou.com"; //SMTP 服务器
$check = 1;
//SMTP需要要身份验证设值为 1 不需要身份验证值为 0,现在大多数的SMTP服务商都要验证,如不清楚请与你的smtp 服务商联系。
if ($check) { $username = "[email protected]"; //您的email帐号名称
$password = "1111111"; //您的email密码
}$s_from = "[email protected]"; //此email 必需是发信服务器上的email
############################################### //连接服务器
$fp = fsockopen ( $smtp, 25, $errno, $errstr, 60);
if (!$fp ) return "联接服务器失败".__LINE__;
set_socket_blocking($fp, true );
$lastmessage=fgets($fp,512);
if ( substr($lastmessage,0,3) != 220 ) return "错误信息A:".$lastmessage.__LINE__;
//HELO
$yourname = "YOURNAME";
if($check == "1") $lastact="EHLO ".$yourname."\r\n";
else $lastact="HELO ".$yourname."\r\n";
fputs($fp, $lastact);
$lastmessage == fgets($fp,512);
if (substr($lastmessage,0,3) != 220 ) return "错误信息B$lastmessage".__LINE__;
while (true) {
$lastmessage = fgets($fp,512);
if ( (substr($lastmessage,3,1) != "-") or (empty($lastmessage)) )
break;
}
//身份验证
if ($check=="1") {
//验证开始
$lastact="AUTH LOGIN"."\r\n";
fputs( $fp, $lastact);
$lastmessage = fgets ($fp,512);
if (substr($lastmessage,0,3) != 334) return "错误信息C$lastmessage".__LINE__;
//用户姓名
$lastact=base64_encode($username)."\r\n";
fputs( $fp, $lastact);
$lastmessage = fgets ($fp,512);
if (substr($lastmessage,0,3) != 334) return "错误信息D$lastmessage".__LINE__;
//用户密码
$lastact=base64_encode($password)."\r\n";
fputs( $fp, $lastact);
$lastmessage = fgets ($fp,512);
if (substr($lastmessage,0,3) != "235") return "错误信息E$lastmessage".__LINE__;
}
//FROM:
//$lastact="MAIL FROM: $s_from" . "\r\n";
$lastact="MAIL FROM: [email protected]" . "\r\n";
fputs( $fp, $lastact);
$lastmessage = fgets ($fp,512);
if (substr($lastmessage,0,3) != 250) return "错误信息F$lastmessage".__LINE__;
//TO:
$lastact="To: $to" . "\r\n";
fputs( $fp, $lastact);
$lastmessage = fgets ($fp,512);
if (substr($lastmessage,0,3) != 250) return "错误信息G$lastmessage".__LINE__;
//DATA
$lastact="DATA\r\n";
fputs($fp, $lastact);
$lastmessage = fgets ($fp,512);
if (substr($lastmessage,0,3) != 354) return "错误信息H$lastmessage".__LINE__;
//处理Subject头
$head="Subject: $subject\r\n";
$message = $head."\r\n".$message;
//处理From头
$head="From: $from\r\n";
$message = $head.$message;
//处理To头
$head="To: $to\r\n";
$message = $head.$message;
//加上结束串
$message .= "\r\n.\r\n";
//发送信息
fputs($fp, $message);
$lastact="QUIT\r\n";
fputs($fp,$lastace);
fclose($fp);
return 0;
} ?>
唠叨老大,你终于出现了,smtp需要身份验证(如上),好像还是不行~~
另外,怎么连接socket扩展库啊
Warning: Failed to Connect in c:\apache\htdocs\mail\i\mail.php 我怀疑是设置或是什么问题,请大侠明示
<?
//作者:秋衫客
print <<< eof
<title>邮件在线发送工具</title>
<style type=text/css>
body{font-size:9pt;background-color:#eeeeee}
td{font-size:9pt}
input,textarea{border-width:1;border-color:#dddddd;font-family:verdana;}
a:link,a:visited{color:#000000;text-decoration:none}
a:hover{color:#7abc01;text-decoration:none;position:relative;left:1;top:1}
</style>
<center><font size=+1><b>邮件在线发送工具</b></font> (<B>利用Socket技术</B>)</center><br>
eof; set_time_limit(120);
if(!$submit||$submit=="")
{
print <<< eof
<table border=0 cellspacing=1 bgcolor=#000000 width=80% align=center>
<tr bgcolor=#dddddd><td colspan=2><center><b>邮件发送 (<font color=red>所有项都必须正确填写,否则不能正常发送。</font>)</b></center></td></tr>
<form action=$PHP_SELF method=post>
<tr bgcolor=#ffffff><td width=40%><p align=right>发信地址:</p></td><td><input type=text name=from> * 推荐使用网易信箱</td></tr>
<tr bgcolor=#ffffff><td><p align=right>发信箱密码:</p></td><td><input type=password name=password></td></tr>
<tr bgcolor=#ffffff><td><p align=right>发信者:</p></td><td><input type=text name=from_name></td></tr>
<tr bgcolor=#ffffff><td><p align=right>收信地址:</p></td><td><input type=text name=to></td></tr>
<tr bgcolor=#ffffff><td><p align=right>收信者:</p></td><td><input type=text name=to_name></td></tr>
<tr bgcolor=#ffffff><td><p align=right>主题:</p></td><td><input type=text name=subject>
<input type=checkbox name=html value=1> 发送超文本信件</td></tr>
<tr bgcolor=#dddddd><td colspan=2><center>邮件内容</center></td></tr>
<tr bgcolor=#ffffff><td colspan=2><center><textarea name=data cols=80 rows=10></textarea>
</center></td></tr>
<tr bgcolor=#dddddd><td colspan=2><center><input type=submit value=发送 name=submit>
<input type=reset value=重置></center></td></tr>
</form>
</table>
eof;
}
else
{
if($from==""||$password==""||$to==""||$subject==""||$data==""||!ereg("^.+@.+\\..+$",$from)||!ereg("^.+@.+\\..+$",$from)){
print "<script>alert('资料填写不完整或者格式出错。');history.back();</script>";
exit;
}
$temp=split("@",$from);
$host="smtp." .$temp[1];
$port=25;
$username=$temp[0];
send_mail($host,$port,$username,$password,$from,$from_name,$to,$to_name,$subject,$data,$html);
}
print <<< eof
<br>
eof;
function send_mail($host,$port,$username,$password,$from,$from_name,$to,$to_name,$subject,$data,$html=0){////////邮件Socket发送函数定义 $fp=@fsockopen($host,$port)or die("无法连接到远程主机!");
$temp=fgets($fp,512);
echo $temp;
die("aa");
//连接远程服务器
//向服务器打招呼
fputs($fp,"HELO $username\n");
$temp=fgets($fp,512);
//ESTMP验证
fputs($fp,"AUTH LOGIN\n");
$temp=ltrim(fgets($fp,512));
fputs($fp,base64_encode($username)."\n");
$temp=ltrim(fgets($fp,512)); fputs($fp,base64_encode($password) ."\n");
$temp=ltrim(fgets($fp,512));
if(substr($temp,0,3)!="235")
{
$result.="<center><font color=red>密码不对!</font></center><br>";
$err=1;
}
if($err!=1)
{
fputs($fp,"mail from:$from\n");
$temp=ltrim(fgets($fp,512));
fputs($fp,"rcpt to:$to\n");
$temp=ltrim(fgets($fp,512));
fputs($fp,"data\n");
$temp=ltrim(fgets($fp,512));
//$temp=eregi_replace("<","<",$temp);
//$temp=eregi_replace(">",">",$temp);
fputs($fp,"To:" .$to ."\n");
fputs($fp,"From:$from_name<" .$from .">\n");
fputs($fp,"Subject:" .$subject ."\n");
if($html==1)
{
fputs($fp,"Content-type:text/html\n");
}
fputs($fp,"$data\n");
fputs($fp,".\n");
$temp=ltrim(fgets($fp,512));
if(substr($temp,0,3)!="250")
{
$result.="<center>由于不可知原因,邮件没有发送成功。</center><br>";
}
else
{
$result.="<center><font color=red>发送成功!</font></center><br>";
}
fputs($fp,"quit\n");
$temp=ltrim(fgets($fp,512));
}
print $result;
global $PHP_SELF;
print "<center><br><a href=$PHP_SELF><b>发送新信件</b></a><br>";
fclose($fp);
}
?>
邮件Socket发送函数定义 $fp=@fsockopen($host,$port)or die("无法连接到远程主机!");
$temp=fgets($fp,512);
echo $temp;
die("aa");这两句可以去掉了 :)
echo $temp;
die("aa");
,mail函数根本发不出去,提示fail to connect....line就是mail那行,用socket提示找不到fuction,可我已经在apache/php/extensions里添加了php_sockets.dll啊,在php.ini里也把php_sockets.dll里的";"去了,还是不行啊,请帮帮我啊~~大侠 [email protected],多谢多谢!!!
是不是在send_mail中把smtp写成"smtp."+domain name而其他的smtp服务器并不叫这个名的原因啊,比如可能叫smtp1.+domain name,请问这个问题有没有一个比较通用的方法?
http://www.mistruster.com/soft/merak.zip
说的邮件服务器相当好用,你也可以试试
我想实现的是用外部的smtp发
不知怎么实现
还有就是mail需要sendmail吗?
这句话不明白
为什么下面的可以实现:
<?php
$to = "[email protected]";
$subject = "if you fool yourself ,you will make him happy! :)";
$content = "this is a test";
$headers = "From: wishyouwerehere1<[email protected]>\r\n";
$sendinfo = mail($to, $subject, $content, $headers);
?>
而改成hotmail的就收不到.
[mail function]
SMTP=localhost
不用写sendmail_path= 用;注释掉在‘开始’菜单里找到
Merak Mail Server -> Merak Mail Server Administrator
执行就可以了。选项卡:[System] 里 [MailServer Host] 填自己的IP
选项卡:[Accounts] 里 先添自己域名(New Domain),不必真实的。
在选中该域时右边的选项卡:[Miscllaneous]有个 [Virtual IP Binding...]
填写你的IP别的基本上就不用配置了……
为什么我总是提示无法连接主机,其中主机怎么设置的。“$host="smtp." .$temp[1];”
$lastact="To: $to" . "\r\n"; //应为:$lastact="RCPT To: $to" . "\r\n";
fputs( $fp, $lastact);
$lastmessage = fgets ($fp,512);
if (substr($lastmessage,0,3) != 250) return "错误信息G$lastmessage".__LINE__;