How to send an eMail via PHP?

The core problem of this challenge is to find an existing PHP-function, which enables a programmer to send an eMail. Furthermore, the correct syntax and the required data of the mail-function is an essential problem.
1 answer

PHP mail() Function

The problem was solved by the creation of the PHP mail()-function.

Programmers have to include the receiver or receivers, subject, message, header (From, Cc, and Bcc) and optional parameter of the eMail.

The syntax of the mail()-function is mail(to,subject,message,headers,parameters).

For an example, see "Screenshot PHP Mail-Function" or the following code-snippet:


<?php
$to = "somebody@example.com";
$subject = "test subject";
$txt = "Hello world!";
$headers = "From: from@example.com" . "\r\n" .
"CC: cc@example.com";
mail($to,$subject,$txt,$headers);
?>

Taggings: