PHP syntax (5)

Source: Internet
Author: User

Body:
You can use the mail () function to send emails online. The format is as follows:
Mail (recipient, subject, content, mail file header );
On the Internet, send an Email to the webmaster, typically like this: <a href = "mailto: webmaster@163.com"> webmaster@163.com </a> so that when you click the webmaste sites r@163.com link, the default mail editor will be started to write emails. This is really troublesome. You can easily compile an online mail page by using the mail () function. The recipient of this sort page is fixed (webmaster@163.com), there is a need to fill in the recipient address, and the subject we can also set it down. For example:
File: email.html
<Html>
<Head>
<Title> send a mail to the network administrator </title>
</Head>
<Body>
<H2 align = "center"> network administrator reception <Hr> <br>
<Center>
<Form action = "mail. php">
Sender: <input type = "text" name = "from" size = 25> <br>
Topic: <input type = "text" name = "subject" size = 20> <br>
Content:
<Textarea name = "content" cols = 80 rows = 15> hello, Webmaster: </textarea> <br>
<Input type = "submit" value = "send"> <input type = "reset" value = "Rewrite"> <br>
</Form>
</Body>
File: mail. php
<? Php
If (empty ($ from) or empty ($ subject) or empty ($ content) {echo "is not completed, <a href = "email.html"> return </a> ";}
$ Body = "[subject] $ subjectn ";
$ Body. = "[Sender] $ fromn ";
$ Body. = $ content;
$ Deal = mail ("webmaster@163.com", $ subject, $ body, "From: $ from ");
If ($ deal) {echo "mail successful! ";} Else {echo" failed to send !!! ";}
?>
It's almost the same as PHP. Do you feel the power of PHP and want to join the ranks of PHP. To make yourself fly in PHP, this knowledge is still insufficient. It can only help you get started. After getting started, you will practice yourself. Goodbye, my friend -- (^_^)
-- (Full text )--

Related Article

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.