Easy Tutorial
❮ Func Xml Parse Into Struct Func String Convert Cyr String ❯

PHP mail() Function



Definition and Usage

The mail() function allows you to send emails directly from a script.

It returns TRUE if the mail was successfully accepted for delivery, otherwise FALSE.

Syntax

Parameter Description
to Required. Specifies the recipient(s) of the email.
subject Required. Specifies the subject of the email. Note: This parameter cannot contain any newline characters.
message Required. Defines the message to be sent. Each line should be separated with a LF (\n). Lines should not exceed 70 characters. Windows Note: When PHP is directly connected to an SMTP server, a single period found at the start of a line will be removed. To solve this, replace single periods with double periods: <br> <?php<br> $txt = str_replace("\n.", "\n..", $txt);<br> ?>
headers Optional. Specifies additional headers, such as From, Cc, and Bcc. Additional headers should be separated with a CRLF (\r\n). Note: When sending an email, it must contain a From header. This can be set via this parameter or in the php.ini file.
parameters Optional. Specifies additional parameters for the sendmail program (defined in the sendmail_path configuration setting). For example, when using the -f sendmail option, it can be used to set the sender address.

Tips and Notes

Note: It is important to remember that the acceptance of email delivery does not guarantee that the email has reached its intended destination.


Example 1

Sending a simple email:


Example 2

Sending an email with additional headers:


Example 3

Sending an HTML email:


❮ Func Xml Parse Into Struct Func String Convert Cyr String ❯