When you do echo mail();
it is calling the function mail()
again but you are not passing any variables to it. Try:
$mail = mail($targetEmail, $subject, $message);
echo $mail;
However, according to the mail() documentation; the function accepts:
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
But you have to set-up the sender email in the $additional_headers variable to be able to send the email. Try this:
$targetEmail = '[email protected]';
$subject = 'Sending e-mails from PHP is fun!';
$message = 'Do you agree?';
$headers = "From: [email protected]" . "\r\n" .
"CC: [email protected]";
$mail = mail($targetEmail, $subject, $message, $headers);
echo $mail;