bool mail
(string to, string subject, string message [, string
additional_headers, string
[additional_parameters]])
mail() automatically mails the message specified in message to the receiver specified in to. Multiple recipients can be specified by putting a comma between each address in to. Email with attachments and special types of content can be sent using this function. This is accomplished via MIME-encoding - for more information, see http://www.zend.com/zend/spotlight/sendmimeemailpart1.php or RFC 1896).
mail() returns TRUE if the mail is successfully sent, FALSE otherwise.
If a fourth string argument is passed, this string is inserted at the end of the header. This is typically used to add extra headers. Multiple extra headers are separated with a carriage return and newline.
Note: You must use \r\n to seperate headers, although some Unix mail transfer agents may work with just a single newline (\n). The Cc: header is case sensitive and must be written as Cc: on Win32 systems. The Bcc: header is also not supported on Win32 systems.
Example 2. Sending mail with extra headers.
|
The additional_parameters parameter can be used to pass additional parameters to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail. You may need to add the user that your web server runs as to your sendmail configuration to prevent a 'X-Warning' header from being added to the message when you set the envelope sender using this method.
Example 3. Sending mail with extra headers and setting an additional command line parameter.
|
Note: This fifth parameter was added in PHP 4.0.5.
You can also use simple string building techniques to build complex email messages.
Example 4. Sending complex email.
|
Note: Make sure you do not have any newline characters in the to or subject, or the mail may not be sent properly.