The previous section gave class_smtp.php. A very important file. Without it, we cannot send an email. Then we can use it to send the information we entered to the text box first.
The previous section provides class_smtp.php. A very important file, without it, we cannot send an email. Then we can use it to send the information we entered. First, we should send the form name = "form1" method = "post" action = "Message_Receive_Add_Email.php" input name =" strContent "type =" text "value =" "/in
The previous section gave class_smtp.php. A very important file. Without it, we cannot send emails.
Next we will use it to send our input information.
First, enter a text box.
Then write a Message_Receive_Add_Email.php
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head> <meta http-equiv =" Content-Type "content =" text/html; charset = gb2312 "/> <title> untitled document </title> </pead> <body> <? Php // receiving parameter strContent $ strContent = $ HTTP_POST_VARS ["strContent"]; echo "<li/> successfully received parameter: strContent = ". $ strContent; // Save the parameter to the database // define the execution SQL statement $ SQL = "insert into db_Message.t_Message ("; $ SQL = $ SQL. "intMessageID, strContent)"; $ SQL = $ SQL. "values (null ,'". $ strContent. "');"; echo "<li/> ". $ SQL; // Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in D:/Apache/htdocs/test/Message_Receive_Add.php on line 20 // connect to the database $ connect = mysql_connect ("localhost", "root", "root") or die ("cannot connect to the database server"); // perform database operations, write data into $ query = mysql_db_query ("db_Message", $ SQL, $ connect) or die ("<li/> !!!! "); Echo" <li/> Save to database: successful! "; // Send the email to require (" class_smtp.php "); // define the relevant parameters $ smtpserver =" smtp.163.com "; // your smtp server address $ port = 25; // The port of the smtp server, usually 25 $ smtpuser = "User Name of your smtp server Logon "; // The user name you log on to the smtp server $ smtppwd = "your password for logging on to the smtp server"; // your password for logging on to the smtp server $ mailtype = "HTML "; // mail type, optional value is TXT or HTML, TXT indicates a plain text mail, HTML indicates an html format of mail $ sender = "cuiran2001@163.com"; // sender, generally, it must be the same as the user name ($ smtpuser) for you to log on to the smtp server. Otherwise, sending may fail due to the smtp server setting $ smtp = new smtp ($ smtpse Rver, $ port, true, $ smtpuser, $ smtppwd, $ sender); echo "<li/>"; $ smtp-> debug = true; // whether to enable debugging, use only when testing the program, comment this line $ to = "115621060@qq.com"; // recipient $ subject = "hello"; $ body = $ strContent; $ send = $ smtp-> sendmail ($ to, $ sender, $ subject, $ body, $ mailtype); if ($ send = 1) {echo "email sent successfully";} else {echo "email failed to be sent <br/>"; echo "cause :". $ this-> smtp-> logs;}?> </Body> </ptml>
Sending result