A very practical complete email sending program

Source: Internet
Author: User

A very practical and complete email sending program is very simple. Just copy the following code to a blank text page, such as index. php, and run it. Specific instance: http://zsvalley.uhome.net/email/index.php.
The following is the complete source code: (if you have any questions, please email: zsvalley@cmmail.com)

<?

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 "Please enter your EMAIL address correctly! <A href = 'javascript: history. go (-1) '> return </A> ";

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

Echo "Please enter your friend's EMAIL address correctly! <A href = 'javascript: history. go (-1) '> return </A> ";

} Else {

$ Message = $ fname. "Hello, nn, your friend ". $ yname. "I want to send a special letter to you: n ------------------------------------- n ". $ comments. "n --------------------------------- nnn service: http://zsvalley.uhome.net/email/nn?#◆ valley network borderless http://valley.coc.cc ◆ n ── ─ n ";

// Send by email
Mail ($ femail, $ title, $ message, "From: $ yemail ");
// Echo nl2br ($ message );
$ OK = 'no ';
Echo "
}
Exit ();
}
?>

<Html>
<Head>
<TITLE> Recommend webpages to friends </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 ("enter your name! ");
}
Else if (document. frmSend. yemail. value. length <1)
{
Alert ("Enter your EMAIL address! ");
}
Else if (document. frmSend. fname. value. length <1)
{
Alert ("Enter your friend's name! ");
}
Else if (document. frmSend. femail. value. length <1)
{
Alert ("Enter your friend's EMAIL address! ");
}
Else document. frmSend. submit ();
}

// ===================================== Dragon code ====================== ======================
Function forHtmlSpecialChars (str) {// Replace special characters in HTML with code
Str = strReplace (str ,"&","&");
Str = strReplace (str ,""",""");
Str = strReplace (str, "<", "<");
Str = strReplace (str, ">", "> ");
Str = strReplace (str, "% 20 ","");
Return str;
}

Function strReplace (str, str1, str2) {// replace all str1 in str with str2.
While (str. search (str1)>-1)
Str = str. replace (str1, str2 );
Return str;
}

Function getParentTitle () {// obtain the parent page title
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> quick email system! </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> topic: </td> <td width = "40%" height = "22" bgcolor = # fdf4db>
<Input class = st1 name = "title" size = "20">
</Td> </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> your name: </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> email address: </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> friend's name: </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> email address: </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"> what you want to say: </td> </tr>
<Tr> <td width = "100%" bgcolor = # fdf4db height = "10" colspan = "2"> <textarea class = st1 rows = "6" name = "comments"
Cols = "36"> </textarea> </td> </tr> <td width = "100%" colspan = "2" bgcolor = # fdf4db> <div align = "center"> <input type = button CLASS = st2
VALUE = "send" NAME = "send" ONCLICK = check ()> </div> </td> </tr> </table> </form> </center> <BR> <! -- # 51Net -->
</Body>
</Html>

[This article is copyrighted by the author and osuo. If you need to reprint it, please indicate the author and its source]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.