Using the Mail function in PHP

Source: Internet
Author: User

Note: The PHP environment is fully configured, refer to http://www.cnblogs.com/homezzm/archive/2012/08/01/2618062.html

1. Local Windows needs to install SMTP server, we recommend using free SMTP server, link--http://www.softstack.com/freesmtp.html

2. After the installation is complete, check your PHP configuration file, which is the following configuration in php.in:

SMTP = localhost
; Http://php.net/smtp-port
Smtp_port = 25

3. Next demo code, create an HTML form input, a PHP file for processing, the local SMTP server acts as a post office outgoing.

(1) feedback.html

1 <formAction= "processfeedback.php"Method= "POST"xmlns= "http://www.w3.org/1999/html">2         <BR>Name</BR>3         <inputtype= "text"name= "Name"size= "6"></P>4         <P>Email</BR>5         <inputTYPR= "text"name= "Email"size= "+"maxsize= "Max"></P>6         <P>Your Feedback</BR>7         <inputtype= "text"style= "height:40px; width:125px"name= "Feedback"></P>8         <P><inputtype= "Submit"value= "Submit"></P>9 Ten </form>

(2) processfeedback.php

1<?PHP2Date_default_timezone_set ("PRC");3 $name=Trim($_post[' Name ']);4 $email=Trim($_post[' Email ']);5 $feedback=Trim($_post[' Feedback ']);6 $toaddress= "[email protected]";//here is the email address of the person you want to serve.7 $emailcontent= "Customer Name:".$name." Feedback: ".$feedback;8 $subject="$feedbackFrom Wed Site ";9 $fromaddress= "From:[email protected]";//the sender is his or her e-mail address, just write one of them.Ten Mail($toaddress,$subject,$emailcontent,$fromaddress);//The first parameter is the recipient address, the second is the title, the third is the content, and the fourth is the sender address One?> A - -<title>bob 's Auto parts-feedback submitted</title> the  - <body> -  - <p>your Feed back has been sent.</p> + <?php - Echo nl2br ($emailcontent); + ?> A </body> at

Using the Mail function in PHP

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.