A simple automatic mail system (I) _ PHP Tutorial

Source: Internet
Author: User
Tags php3 file
A simple automatic mail system (1 ). Another powerful feature of php, a simple automatic mail system, is its ability to modify variables through html forms. with these variables, we can implement many tasks, package a simple automatic mail system
Another powerful feature of php is its ability to modify variables through html forms. with these variables, we can implement many tasks, including sending wed-based emails, output information to the screen to read and transmit data from the database. Let's build a small automatic mail system to demonstrate this capability.
Let's assume there is an html form:

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



Request for more information


Wocould you like more information about our company?











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

Save this file as moreinfo.html

Note that action points to the File: email. php3 contains 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 users enter their name and email in the form, click "send it !" Button, the form will call the e-mail. php3 file, in turn as shown below :( Here we assume that the person 'name is bill, the e-mail address is bgates@devshed.com, select apples ):

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

Thank you for your interest.

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

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

In this way, our project has not been completed yet. because we do not know who has inserted some information and there has been nothing substantive, we have no way to send a mail to bill.

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

· To --- send an email to the specified email address
· Subject indicates the topic.
· Message indicates the content of a letter.
· Additional _ headers can be omitted, indicating other mail file headers.

Therefore, if we insert this command into the print statement, we can automatically send emails to users and websites so that we can know who needs the information.

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

Mail ("$ email", "Your request for information", "$ namen
Thank you for your interest! NWe must 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. Therefore, in most cases, determine whether it can be used before use.

However, when many people fill in the information, as a manager, you cannot browse the letters one by one. you can use the database to track how many people choose apples and how many choose oranges? There are many such databases, one of the fastest of which is mysql.

In the next article, I will introduce how to combine php and mysql.

Another powerful feature of php is its ability to modify variables through html forms. through these variables, we can implement many tasks, packages...

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.