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.
*/