很实用的一个完整email发送程序

2018-09-07 11:46

阅读:651

  很实用的一个完整email发送程序,很简单,把下列代码复制到一个空白文本页面,如index.php,运行就行了。具体实例:。
以下是完整的源代码:(有任何问题请email:

<?

if ($ok==yes){
//SetCookie("yname", $yname);
//SetCookie("yemail", $yemail);

if (!eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$yemail)){

echo "请正确填写您的EMAIL地址! <A HREF=javascript:history.go(-1)>返回</A>";

}elseif(!eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$femail)){

echo "请正确填写您好友的EMAIL地址! <A HREF=javascript:history.go(-1)>返回</A>";

}else{

$message=$fname.",你好:nn你的朋友".$yname."特地来信想对向您说:n-----------------------------------n".$comments."n-----------------------------------nnn提供服务:◆◆◆ valley网络无界限◆◆◆n─────────────────────────n";

//email发送
mail($femail, $title, $message,"From: $yemail");
//echo nl2br($message);
$ok=no;
echo "<html><body>".nl2br($message)."<BR><BR><A HREF=index.php>回到发送页面</A></body></html><script language="javascript">alert("发送成功!"); </script>";

}
exit();
}
?>

<html>
<head>
<TITLE>将网页推荐给好友</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE type=text/css>BODY {
FONT-SIZE: 14px; LINE-HEIGHT: 18px
}
TD {
FONT-SIZE: 14px; LINE-HEIGHT: 18px
}
.st1 {
BACKGROUND-COLOR: #ffcc66; BORDER-BOTTOM: #ffcc66 1px solid; BORDER-LEFT: #ffcc66 1px solid; BORDER-RIGHT: #ffcc66 1px solid; BORDER-TOP: #ffcc66 1px solid; COLOR: #aa0000; FONT-SIZE: 9pt
}
.st2 {
BACKGROUND-COLOR: #ffcc66; BORDER-BOTTOM: #ec9f00 1px solid; BORDER-LEFT: #ffffff 1px solid; BORDER-RIGHT: #ec9f00 1px solid; BORDER-TOP: #ffffff 1px solid; COLOR: #aa0000; FONT-SIZE: 9pt; HEIGHT: 20px; WIDTH: 60px
}
</STYLE>
<script language=JavaScript runat=Server>
function check()
{
if (document.frmSend.yname.value.length<1)
{
alert("请填写您的姓名!");
}
else if (document.frmSend.yemail.value.length<1)
{
alert("请填写您的EMAIL地址!");
}
else if (document.frmSend.fname.value.length<1)
{
alert("请填写您好友的姓名!");
}
else if (document.frmSend.femail.value.length<1)
{
alert("请填写您好友的EMAIL地址!");
}
else document.frmSend.submit();
}

//=====================DRAGON CODE===============================
function forHtmlSpecialChars(str){ //将HTML中的特殊字符替换成代码
str=strReplace(str,"&","");
str=strReplace(str,""",""");
str=strReplace(str,"<","<");
str=strReplace(str,">",">");
str=strReplace(str,"%20"," ");
return str;
}

function strReplace(str,str1,str2){ //将str中的所有str1替换城str2
while(str.search(str1)>-1)
str=str.replace(str1,str2);
return str;
}

function getParentTitle(){//获取父页的标题
str=location.href;
str=str.substring(12,str.length);
return str;
}
//======================================================
</script>
<META content="MSHTML 5.00.2920.0" name=GENERATOR>
</head>
<body bgColor=white link=#ec9f00 text=#aa0000>
<center> <H3>快速email系统!</H3><FORM name=frmSend ACTION=index.php METHOD=POST onsubmit="return check();">
<INPUT TYPE="hidden" NAME="referer" value="<?echo $referer;?>"><INPUT TYPE="hidden" NAME="ok" VALUE="yes"><INPUT TYPE="hidden" NAME="title" VALUE="<?echo $parentTitle;?>"><table bgColor=#e99b0a border=0 cellPadding=2 cellSpacing=1>
<tr> <td width="40%" height="22" bgColor=#fdf4db>主题:</td><td width="40%" height="22" bgcolor=#fdf4db>
<input class=st1 name="title" size="20" >
</td></tr> <tr> <td width="40%" height="10" bgColor=#fdf4db></td><td width="60%" height="10" bgcolor="#fdf4db"></td></tr>
<tr> <td width="40%" height="22" bgColor=#fdf4db>您的姓名:</td><td width="60%" height="22" bgcolor=#fdf4db><input class=st1 name="yname" size="20" value=<?echo $yname?>></td></tr>
<tr> <td width="40%" height="10" bgcolor=#fdf4db></td><td width="60%" height="10" bgcolor=#fdf4db></td></tr>
<tr> <td width="40%" height="22" bgcolor=#fdf4db>邮件地址:</td><td width="60%" height="22" bgcolor=#fdf4db><input class=st1 name="yemail" size="20" value=<?echo $yemail?>></td></tr>
<tr> <td width="40%" height="10" bgcolor=#fdf4db></td><td width="60%" height="10" bgcolor=#fdf4db></td></tr>
<tr> <td width="40%" height="22" bgcolor=#fdf4db>朋友的姓名:</td><td width="60%" height="22" bgcolor=#fdf4db><input class=st1 name="fname" size="20" value=></td></tr>
<tr> <td width="40%" height="10" bgcolor=#fdf4db></td><td width=60%height="10" bgcolor=#fdf4db></td></tr>
<tr> <td width="40%" height="22" bgcolor=#fdf4db>邮件地址:</td><td width=60%height="22" bgcolor=#fdf4db><input class=st1 name="femail" size="20" value=></td></tr>
<tr> <td width="40%" height="10" bgcolor=#fdf4db></td><td width=60%height="10" bgcolor=#fdf4db></td></tr>
<tr> <td width="100%" height="22" bgcolor=#fdf4db colspan="2">您想说的话:</td></tr>
<tr> <td width="100%" bgcolor=#fdf4db height="10" colspan="2"><textarea class=st1 rows="6" name="comments"
cols="36"></textarea></td></tr> <tr> <td width="100%" colspan="2" bgcolor=#fdf4db><div align="center"><INPUT TYPE=button CLASS=st2
VALUE="发送" NAME="send" ONCLICK=check()></div></td></tr> </table></form></center><BR><!--#51Net -->
</body>
</html>

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】


评论


亲,登录后才可以留言!