A simple automatic email sending system (1)_PHP tutorial

WBOY
Release: 2016-07-21 16:06:38
Original
963 people have browsed it

A simple automatic email sending system
Another powerful feature of PHP is its ability to modify variables through HTML forms. Through these variables, we can achieve many tasks, including: sending wed-based emails, Output information to the screen, read and pass data from the database. Let's build a small automatic email sending system to demonstrate this capability.
Let us assume there is such an html form:

---------------------------------- -------



Request for more information


Would you like more information about our company?







Your name:



Your email address:



I prefer:









----- ----------------------------------

Save this file as moreinfo.html

Note that the action points to the file: email.php3 Here is the email.php3 file:

-------------------------- ------------

/* this script will handle the variables passed from the moreinfo.html file */
PRINT "
";PRINT "Hello, $name.";PRINT "

";
PRINT "Thank you for your interest.

";
PRINT "We will send information to $email, and have noted that you like $preference.";
PRINT "
";
?>

-------- -------------------------------

Save the above file as email.php3

When the user types their name and email into the form, click "send it!" " button, the form will call the email.php3 file, which is displayed as follows: (Here we assume that the person's name is bill, the email address is bgates@devshed.com, and apples is selected):

---- ----------------------------------
Hello, Bill.

Thank you for your interest.

We will send information to bgates@devshed.com, and have noted that you like Apples

----------------- ---------------------

Our project has not been completed yet, because we don’t know who has inserted some information, and there is no substance. Something sexual has happened and we have no way to send a letter to bill.

In order to reduce the burden of sending standard emails manually, we can use the PHP mail() command. Syntax: void mail(string to). , string subject, string message, string add_headers);

·to---send an email to the specified email address
·subject represents the subject
·message is the content of the letter
· additional_headers can be omitted, indicating other email file headers

Therefore, if we insert this command after the print statement, we can automatically send letters to users and website owners to let us know who needs it. This information.

-------------------------------------

mail("$email", "Your request for information", "$namen
Thank you for your interest!nWe sell fresh corn daily over the Internet!
Place your order at http://www.buycorn.com,
and receive a free package of $preference!");
mail("administration@buycorn.com",
"Visitor request for info.", "$name requested for information.n
The email address is $email. n The visitor prefers $preference.");
?>

---------- ----------------------------

Note: The mail() function can only be used when SENDMAIL is installed on the server. , so, in most cases, make sure it can be used before using it.

But when many people fill in the information, as a manager, it is impossible for you to browse the letters one by one. You can use a database to track how many people chose apples and how many people chose oranges? There are many types of such databases, one of the fastest is mysql.

In the next article, I will introduce to you how to use php and mysql together.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315415.htmlTechArticleA simple automatic email sending system. Another powerful feature of php is that it can modify variables through html forms. Ability, through these variables, we can achieve many tasks, including...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!