Php mail email sending code

Source: Internet
Author: User
Tags configuration settings ini php file

?>

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)

 

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.