关于php发送mail的问题,急切想知道,请大家多多关注! 除了用MAIL()还可以采用调用邮件服务器上的sendmail的命令来实现! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?/* * email_validation.php * * @(#) $Header: /cvsroot/PHPlibrary/email_validation.php,v 1.4 1999/11/02 06:19:35 mlemos Exp $ * */class email_validation_class{ var $email_regular_expression="^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}"; var $timeout=0; var $localhost=""; var $localuser=""; Function GetLine($connection) { for($line="";;) { if(feof($connection)) return(0); $line.=fgets($connection,100); $length=strlen($line); if($length>=2 && substr($line,$length-2,2)=="\r\n") return(substr($line,0,$length-2)); } } Function PutLine($connection,$line) { return(fputs($connection,"$line\r\n")); } Function ValidateEmailAddress($email) { return(eregi($this->email_regular_expression,$email)!=0); } Function ValidateEmailHost($email,$hosts=0) { if(!$this->ValidateEmailAddress($email)) return(0); $user=strtok($email,"@"); $domain=strtok(""); if(GetMXRR($domain,&$hosts,&$weights)) { $mxhosts=array(); for($host=0;$host<count($hosts);$host++) $mxhosts[$weights[$host]]=$hosts[$host]; KSort($mxhosts); for(Reset($mxhosts),$host=0;$host<count($mxhosts);Next($mxhosts),$host++) $hosts[$host]=$mxhosts[Key($mxhosts)]; } else { $hosts=array(); if(strcmp(@gethostbyname($domain),$domain)!=0) $hosts[]=$domain; } return(count($hosts)!=0); } Function VerifyResultLines($connection,$code) { while(($line=$this->GetLine($connection))) { if(!strcmp(strtok($line," "),$code)) return(1); if(strcmp(strtok($line,"-"),$code)) return(0); } return(-1); } Function ValidateEmailBox($email) { if(!$this->ValidateEmailHost($email,&$hosts)) return(0); if(!strcmp($localhost=$this->localhost,"") && !strcmp($localhost=getenv("SERVER_NAME"),"") && !strcmp($localhost=getenv("HOST"),"")) $localhost="localhost"; if(!strcmp($localuser=$this->localuser,"") && !strcmp($localuser=getenv("USERNAME"),"") && !strcmp($localuser=getenv("USER"),"")) $localuser="root"; for($host=0;$host<count($hosts);$host++) { if(($connection=($this->timeout ? fsockopen($hosts[$host],25,&$errno,&$error,$this->timeout) : fsockopen($hosts[$host],25)))) { if($this->VerifyResultLines($connection,"220")>0 && $this->PutLine($connection,"HELO $localhost") && $this->VerifyResultLines($connection,"250")>0 && $this->PutLine($connection,"MAIL FROM: <$localuser@$localhost>") && $this->VerifyResultLines($connection,"250")>0 && $this->PutLine($connection,"RCPT TO: <$email>") && ($result=$this->VerifyResultLines($connection,"250"))>=0) { fclose($connection); return($result); } fclose($connection); } } return(-1); }};?>祝您好运! 可以的:在PHP中有个函数叫:HTMLSpecialChars,用来把一些特殊的字符转换成HTML的格式举个例子:$Text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=\\1>\\1</a>",$Text); 这是一个支持连接的语句,当然你可以定义很多这样的HTML,不过有点麻烦。:) 你只要把正文内容格式处理成MIME的邮件格式就行了。那样的话,你就可以发送有附件而且任何类型的邮件方式。 求助,关于一条用户输入的条件判定 怎么将2011年5月转化为2011-5-1 header()跳转问题 使用同名checkbox的问题 url过码后,php程序获取参数出现乱码 PHP 无限循环获取数据(或消息)信息 用php连接odbc,用什么方法传回行记录? 怎么验证一个信箱的有效性!? 我找不到它!!! 求助各位大神们,php后台怎么实现直接接受前台的JSON对象information,使用js和ajax如何把JSON对象传递给php后台? 一个使用php做多进程的例子 急,谁有这经验???
/*
* email_validation.php
*
* @(#) $Header: /cvsroot/PHPlibrary/email_validation.php,v 1.4 1999/11/02 06:19:35 mlemos Exp $
*
*/class email_validation_class
{
var $email_regular_expression="^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}";
var $timeout=0;
var $localhost="";
var $localuser=""; Function GetLine($connection)
{
for($line="";;)
{
if(feof($connection))
return(0);
$line.=fgets($connection,100);
$length=strlen($line);
if($length>=2
&& substr($line,$length-2,2)=="\r\n")
return(substr($line,0,$length-2));
}
} Function PutLine($connection,$line)
{
return(fputs($connection,"$line\r\n"));
} Function ValidateEmailAddress($email)
{
return(eregi($this->email_regular_expression,$email)!=0);
} Function ValidateEmailHost($email,$hosts=0)
{
if(!$this->ValidateEmailAddress($email))
return(0);
$user=strtok($email,"@");
$domain=strtok("");
if(GetMXRR($domain,&$hosts,&$weights))
{
$mxhosts=array();
for($host=0;$host<count($hosts);$host++)
$mxhosts[$weights[$host]]=$hosts[$host];
KSort($mxhosts);
for(Reset($mxhosts),$host=0;$host<count($mxhosts);Next($mxhosts),$host++)
$hosts[$host]=$mxhosts[Key($mxhosts)];
}
else
{
$hosts=array();
if(strcmp(@gethostbyname($domain),$domain)!=0)
$hosts[]=$domain;
}
return(count($hosts)!=0);
} Function VerifyResultLines($connection,$code)
{
while(($line=$this->GetLine($connection)))
{
if(!strcmp(strtok($line," "),$code))
return(1);
if(strcmp(strtok($line,"-"),$code))
return(0);
}
return(-1);
} Function ValidateEmailBox($email)
{
if(!$this->ValidateEmailHost($email,&$hosts))
return(0);
if(!strcmp($localhost=$this->localhost,"")
&& !strcmp($localhost=getenv("SERVER_NAME"),"")
&& !strcmp($localhost=getenv("HOST"),""))
$localhost="localhost";
if(!strcmp($localuser=$this->localuser,"")
&& !strcmp($localuser=getenv("USERNAME"),"")
&& !strcmp($localuser=getenv("USER"),""))
$localuser="root";
for($host=0;$host<count($hosts);$host++)
{
if(($connection=($this->timeout ? fsockopen($hosts[$host],25,&$errno,&$error,$this->timeout) : fsockopen($hosts[$host],25))))
{
if($this->VerifyResultLines($connection,"220")>0
&& $this->PutLine($connection,"HELO $localhost")
&& $this->VerifyResultLines($connection,"250")>0
&& $this->PutLine($connection,"MAIL FROM: <$localuser@$localhost>")
&& $this->VerifyResultLines($connection,"250")>0
&& $this->PutLine($connection,"RCPT TO: <$email>")
&& ($result=$this->VerifyResultLines($connection,"250"))>=0)
{
fclose($connection);
return($result);
}
fclose($connection);
}
}
return(-1);
}
};?>
祝您好运!
在PHP中有个函数叫:HTMLSpecialChars,用来把一些特殊的字符转换成HTML的格式
举个例子:
$Text=preg_replace("/\[url\](.+?)\[\/url\]/is","<a href=\\1>\\1</a>",$Text);
这是一个支持连接的语句,当然你可以定义很多这样的HTML,不过有点麻烦。:)