0

Hi my form says "successfully sent". I already uploaded my code in C-panel and updated my gmail security to accept less secure apps. Still no emails in spam or inbox. I appreciate the help guys thanks!

PHP CODE

<?php

$send_to = "jmjmistica@gmail.com";
$send_subject = "Ajax form";




$f_name = cleanupentries($_POST["name"]);
$f_email = cleanupentries($_POST["email"]);
$f_phone = cleanupentries($_POST["phone"]);
$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\nE-Mail: " . $f_phone . 
"\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;
    }
}

?>

I am new in sending emails so if you find an open error I'll appreciate all your suggestions

  • Have you receive "bounce emails"? In case of "(re)try later" email delivery problems typically "warning" message is sent after 4 hours and "failure" after 5 days. – AnFi Dec 20 '20 at 08:34
  • Checked your server's mail logs yet? – Markus AO Dec 20 '20 at 08:46
  • Using `mail()` presupposes that you have a properly set up and configured mail server to handle the mail. If you don't your mail will go nowhere, whatever GMail is set up to accept. – Tangentially Perpendicular Dec 20 '20 at 09:15

0 Answers0