?>
The code is as follows: |
Copy code |
<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> Mail. Php file code
<? Php If (empty ($ from) or empty ($ subject) or empty ($ content )){ Echo "not completed. Please <a href?'mail.html '> return </a> "; } $ Body = "[Subject] $ subjectn "; $ Body. = "[sender] $ fromn "; $ Body. = $ content; $ Deal = mail ("guoanyuan@eyou.com", $ subject, $ body, "from: $ from "); If ($ deal) {echo "mail successful! ";} Else {echo" failed to send !!! ";} ?> |
Php mail functions
Mail introduction
The http function allows you to send emails directly from scripts.
Requirement
To make the email function available, php requires an installed and running email system. The program to be used is defined by the configuration settings in the php. ini file.
Install
Email functions are the core component of php. These functions can be used without installation.
Runtime configuration
The behavior of the email function is affected by php. ini.
Mail configuration options
The default name description can be changed.
Smtp "localhost" for windows: The dns name or ip address of the smtp server. Php_ini_all
Smtp_port "25" for windows: smtp segment slogan. Available from php 4.3. Php_ini_all
Sendmail_from null for windows: specifies the "from" address used in emails sent from php. Php_ini_all
Sendmail_path null dedicated for unix systems: specifies the sendmail program path (usually/usr/sbin/sendmail or/usr/lib/sendmail)