The mail() function requires an installed and working
email subsystem for sending mail. The program to be used is defined by
configuration directives in the php.ini file. A common pitfall is that
these are not set up correctly, rendering mail() inoperable. Note that
the first two directives are for use only on Windows systems; the third is for
use only on Unix-type systems.
-
SMTP: The host to which to connect to send mail. Can be either a fully qualified hostname or an IP address. Used only on Windows systems.
-
sendmail_from: The email address from which sent mail should appear to have been sent. Used only on Windows systems.
-
sendmail_path: Full pathname of the mail executable to run when sending mail. This can also include command-line arguments. The default is created during the precompilation configuration: For example, if a sendmail executable is found in /usr/sbin, the default will be usr/sbin/sendmail -t -i. If no sendmail executable is found, one must be specified here. Used only on Unix-type systems.
bool mail(string recipient, string subject, string message, [string extra_headers], [string extra_arguments])
recipient
|
Address of the recipient
|
subject
|
Message subject
|
message
|
Body of the message
|
extra
|
Extra headers for the message
|
extra_arguments
|
Extra arguments for the underlying mail program
|
Sends a message by email.
$address = 'testen@example.net';
$subject = 'This is a test';
$message = 'Hi there,
This is a test message.
';
mail($address, $subject, $message);