PHP - mail
Trieda
Metóda - mail
(PHP 4, PHP 5, PHP 7)
The function is used for sending emails.
Procedurálne
- function mail (string $to, string $subject, string $message, string $additional_headers, string $additional_parameters) : bool
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $to | string | The e-mail address of the receiver or the receivers according to the RFC 2822 standard. Multiple receivers are separated by comma. Possible variants are for example:
| |
| $subject | string | The e-mail subject acording to the RFC 2047 standard. | |
| $message | string | The e-mail body. Note: The lines should be separated with CRLF (\r\n) and should not be longer than 70 characters. | |
| $additional_headers | string | Additional headers. For example Note: Every line must be separated using CRLF (\r\n). | |
| $additional_parameters | string | Can be used to pass additional parameters to the application used for sending e-mails. |
Mávratovej hodnoty
Vracia: bool
Return true on success, false otherwise.
Príklady
Note: The mail() function is disabled in this
sandbox, so you can't send the actual mail from this online example.
Basic usage:
<?php
$mail = mail('[email protected]', 'Reminder', 'See you tomorrow at 10 AM. Do not forget!');
if ($mail)
echo 'The email has been successfully sent!';
else
echo 'An error while sending email!';
Multiple receivers and setting additional headers:
<?php
$mail = mail('[email protected], [email protected]', 'Lunch', 'When are we going to lunch? It is 1 PM, I am hungry!', 'From: [email protected]');
if ($mail)
echo 'The email has been successfully sent!';
else
echo 'An error while sending email!';
