PHP email header not allowing mail to be received.

Status
Not open for further replies.

mikelons

New Member
Messages
16
Reaction score
0
Points
1
Hello, I am still having issues with emails not arriving in my account due to the PHP email header in my code that allow me to format the emails users send me. The header are simple and should allow emails to arrive in my inbox without issue. I am on server named "absolut" and my email address is mike@mikelonsdale.co.uk

Here is the PHP code

PHP:
<?php
    $to = "mike@mikelonsdale.co.uk";
    $subject = "Feedback from Your Website.";
    $email = ($_POST['email']);
    $name = ($_POST['name']);
    $reason = ($_POST['Subject']);
    $message = ($_POST['feedback']);
    $ip = $_SERVER['REMOTE_ADDR'];

    $headers = "From: " . strip_tags($_POST['email']) . "\r\n";         //Header causing the problem - Places users email in From field
    $headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";     //Header causing the problem - Add users email in the reply to field
    $headers .= "MIME-Version: 1.0\r\n";                                //Header causing the problem - set MIME version.

    $text = "Ip Address: " . $ip . "\r\n";
    $text .= "Name: " . $name . "\r\n";
    $text .= "Email: " . $email . "\r\n";
    $text .= "Reason for feedback: " . $reason . "\r\n";
    $text .= "Message: " . $message . "\r\n";

    //check to see the required fields have been filled in.
    if (empty($_POST["name"]) || empty($_POST["email"]) || empty($_POST["feedback"]))
        {
            include ("contact_error.html");
        }
        elseif (!filter_var($email, FILTER_VALIDATE_EMAIL))
        {
            include ("contact_email.html");
        }
        else
        {
            //send email
            mail($to, $subject, $text, $headers);
            include ("contact_sent.html");
        }
?>
 
Last edited:

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Reply-To should be fine, but you're not allowed to spoof the sender (From absolutely MUST be a valid email address that exists in your account), and you have to include a plain text part. These policies and settings are not going to change due to their continuing use for spam/phishing, which gets the Free Hosting servers and domains added to various blacklists. The choice boils down to relatively unformatted mail with your account as the sender, or no ability to send mail at all, for anybody almost all of the time.
 
Status
Not open for further replies.
Top