I am just wondering if anybody sees any error here, the code executes but I never get the email, any suggestions?
$to = $_POST['to_email'];
$subject = $_POST['subject'];
$message='<p><b>Message:</b> '.str_replace("\n.", "\n..", $_POST['message']).'</p>';
$headers = "From: " . strip_tags($_POST['from_email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['from_email']) . "\r\n".
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
This will depend on the setup of PHP.
There are a number of things PHP can do – the most common are queue the email to a local mail server (common on linux, less so on windows) or talk to an external mail relay and queue the mail there (usually requires authentication unless it’s an open relay which is rare). It’s also possible to write to file.
All that the
mail()function guarantees if there are no warnings is that the email has been queued to the location specified in the php.ini file.The first thing to do is check that mail is reporting success…
The next thing you need to do is check your
php.iniconfig to see how email is configured. Make sure it points at a valid mail server with the correct credentials. If you’re on linux and using a local mail server like postfix, check that it’s running (something like/etc/init.d/postfix statusdepending on your distro)As mentioned by @FlorianKasper, SMTP as an option is only available on Windows. If you can clarify exactly what OS you’re using, we may be able to help further.