Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29957

`email is not valid format` on mobile browser when sending PHP form based on `mail-it`

$
0
0

I'm a bit of a newbie when it comes to php and i'm having issues with the following code. This works just fine when I'm opening the page containing the contact form on a laptop browser. However when i use a browser on a mobile device (IPhone), it comes up with the following error, regardless of what email address i put into the form:

email is not a valid format

I tried replacing "\r\n" with "\n" as I saw in another post on here but no luck.

If needed ask any further detail helping to find a solution, maybe with clear steps on how to obtain infos. Thanks!

<?php

/* Code by David McKeown - craftedbydavid.com */
/* Editable entries are bellow */

$send_to = "someone@emailaddress.com ";
$send_subject = "Website Enquiry";



/*Be careful when editing below this line */

$f_name = cleanupentries($_POST["name"]);
$f_email = cleanupentries($_POST["email"]);
$f_message = cleanupentries($_POST["message"]);
$from_ip = $_SERVER['REMOTE_ADDR'];
$from_browser = $_SERVER['HTTP_USER_AGENT'];

function cleanupentries($entry) {
    $entry = trim($entry);
    $entry = stripslashes($entry);
    $entry = htmlspecialchars($entry);

    return $entry;
}

$message = "This email was submitted on " . date('m-d-Y') . 
"\n\nName: " . $f_name . 
"\n\nE-Mail: " . $f_email . 
"\n\nMessage: \n" . $f_message . 
"\n\n\nTechnical Details:\n" . $from_ip . "\n" . $from_browser;

$send_subject .= " - {$f_name}";

$headers = "From: " . $f_email . "\r\n" .
"Reply-To: " . $f_email . "\r\n" .
"X-Mailer: PHP/" . phpversion();

if (!$f_email) {
    echo "no email";
    exit;
}else if (!$f_name){
    echo "no name";
    exit;
}else{
    if (filter_var($f_email, FILTER_VALIDATE_EMAIL)) {
        mail($send_to, $send_subject, $message, $headers);
        echo "true";
    }else{
        echo "invalid email";
        exit;
    }
}

?>

Viewing all articles
Browse latest Browse all 29957

Latest Images

Trending Articles



Latest Images