First of all, try writing PHP code at the top of the web page by checking the input type in POST.
Also, have you configured or checked the functionality of sending mail on your server? By default, it is not installed / enabled. Try sending simple mail first to check it, and if that doesn't work, contact your server administrator immediately or send a support ticket to your server.
Edit: - From your code, usually the "$ testmail" variable will always provide the value "TRUE" or "1" if the syntax of the "mail ()" function is correct. It will return only false if mail was not queued for delivery.
Another point: try using the following code: -
mail($to, $subject, $message, $headers, " -femail.address@example.com ");
where "$ headers" will contain the appropriate headers, and the fifth parameter may be your email address, previously overlaid with "-f".
<?php $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "From: My site< noreply@my _site.com>" . "\r\n"; $headers .= "Reply-To: info@my _site.com" . "\r\n"; $headers .= "Return-Path: info@my _site.com" . "\r\n"; $headers .= "X-Mailer: PHP/" . phpversion() . "\r\n"; ?>
source share