Question:Explain the parameters of PHP’s mail function.
Answer
Example:
<?php
mail("client@example.com","This is a subject","This is the mail body","from:admin@example.com\r\n");
?>
The PHP mail() function is used to send emails from inside a script.
Prototype:
boolean mail(string to, string subject, string message [, string addl_headers [, string addl_params]])
| Parameter | Description |
| to | Required. Specifies the receiver / receivers 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 |
| headers | Optional. Specifies additional headers, like From, Cc, and Bcc. The additional headers should be separated with a CRLF (\r\n) |
| parameters | Optional. Specifies an additional parameter to the sendmail program |
Example:
<?php
mail("client@example.com","This is a subject","This is the mail body","from:admin@example.com\r\n");
?>