NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - mail

Trieda

Koreň \ Bez triedy

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ázovDátový typPredvolená hodnotaPopis
$tostring

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:

$subjectstring

The e-mail subject acording to the RFC 2047 standard.

$messagestring

The e-mail body.

Note: The lines should be separated with CRLF (\r\n) and should not be longer than 70 characters.

$additional_headersstring

Additional headers. For example From, Reply-To, Cc.

Note: Every line must be separated using CRLF (\r\n).

$additional_parametersstring

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!';

Súvisiace manuály

        Aktivity