0

So I am creating a simple website and on the "contact us" page I have put a contact form that is supposed to mail the message there. The form actually gives a success message that the email is sent but I'm not getting any. I have checked the spam/junk folder as well. I tested this on apache local server. (My email is correct. I've stated it like that on the code here for privacy issues.) Can I please have some insight on what I am missing since I am fairly new to coding?

 <?php
header('Content-type: application/json');
$status = array(
    'type'=>'success',
    'message'=>'Mesazhi u dergua!'
);
$name = @trim(stripslashes($_POST['emri'])); 
$email = @trim(stripslashes($_POST['email'])); 
$phoneno = @trim(stripslashes($_POST['telefon']));
$message = @trim(stripslashes($_POST['mesazhi'])); 
$email_from = $email;
  $email_to = 'name.surname@mail.net';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Phone NO: ' . $phoneno . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die; 

?>

<div class="contact-form">
            <form action="sendemail.php" name="contact-form" method="post">
                <input type="text" name="emri" placeholder="Emri" />
                <input type="email" name="email" placeholder="Email" />
                <input type="tel" name="telefon" placeholder="Nr Telefoni"/>
                <textarea name="text" id="text" rows="8" placeholder="Teksti" name="mesazhi"></textarea>
                <input type="submit" class="btn-send" value="Dergo">
            </form>
        </div>
Teabx
  • 133
  • 3
  • 12

2 Answers2

0

Use this code mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

Ed Ward
  • 26
  • 3
-1

you are using a @ on each function call. Remove them and you will maybe see where the problem is.

Doğan Uçar
  • 166
  • 3
  • 15