Php mail () function sends email code

Source: Internet
Author: User

Syntax
Mail (to, subject, message, headers, parameters) parameter description
To is required. Specifies the email recipient.
Subject is required. Specifies the subject of the email. Note: this parameter cannot contain any new line characters.
Message is required. Defines the message to be sent. Lf (n) should be used to separate the rows.
Headers is optional. Specify additional titles, such as from, cc, and bcc.

Crlf (rn) should be used to separate additional titles.
 
Optional. Specify additional parameters for the email sending program.


*/
$ To = 'Nobody @ example.com '; // defines the email address.
$ Subject = 'mail'; // defines the subject of the sent email.
$ Message = 'Hello, php'; // defines the subject content of the email.
$ Headers = 'from: webmaster@example.com '. "rn ".
'Reply-to: webmaster@example.com '. "rn ".
'X-mailer: php/'. phpversion (); // define additional information
Mail ($ to, $ subject, $ message, $ headers); // send an email
?>
<? Php
// Example of sending an html email
$ To = 'Test @ example.com '.',';
$ To. = 'test1 @ example.com '; // defines multiple recipient addresses
$ Subject = 'mailhtml '; // defines the Mail title.
// The following is the html code of the email.
$ Message ='
<Html>
<Head>
<Title> birthday reminders for August </title>
</Head>
<Body>
<P> here are the birthdays upcoming in August! </P>
<Table>
<Tr>
<Th> person </th> <th> day </th> <th> month </th> <th> year </th>
</Tr>
<Tr>
<Td> joe </td> <td> 3rd </td> <td> August </td> <td> 1970 </td>
</Tr>
<Tr>
<Td> sally </td> <td> 17th </td> <td> August </td> <td> 1973 </td>
</Tr>
</Table>
</Body>
</Html>
';
// Send an http request
$ Headers = 'Mime-version: 1.0 '. "rn"; // define additional information
$ Headers. = 'content-type: text/html; charset = iso-8856-1 '. "rn ";
$ Headers. = 'to: mary <mary@example.com>, kelly <kelly@example.com>'. "rn ";
$ Headers. = 'from: birthday reminder <birthday@example.com>'. "rn ";
$ Headers. = 'http: birthdayarchive@example.com '. "rn ";
$ Headers. = 'bcc: birthdaycheck@example.com '. "rn ";
Mail ($ to, $ subject, $ message, $ headers); // execute the send operation

/*

Note: php requires an installed and running email system to make the email function available. The program used is defined through configuration settings in the php. ini file.

*/

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.