很實用的一個完整email發送程序,很簡單,把下列代碼復制到一個空白文本頁面,如index.php,運行就行了。具體實例:http://zsvalley.uhome.net/email/index.php。
以下是完整的源代碼:(有任何問題請email:
[email protected])
<?
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提供服務:http://zsvalley.uhome.net/email/nn◆◆◆ valley網絡無界限 http://valley.coc.cc ◆◆◆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(str.indexOf("parentTitle"),str.indexOf("parentTitleEnd"));
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>
【本文版權歸作者與奧索網共同擁有,如需轉載,請注明作者及出處】