0

When I try to send mail using the PHP

<form action="tester.php" method="post">
 FullName<input type="text" name='name'><br>
    Email<input type="email" id="email-input" name='email-try'>
    <button type="submit">Send</button>
    <br/>
    
</form>

<?php
$to = $_POST['email-try'];
$name = $_POST['name'];

$subject = "My Email Trial";
$txt = "Hey my name is ".$name." and I'm trying to see if this will work";
$headers = "From: supporter@gmail.com";

mail($to,$subject,$txt,$headers);

header("location: type.html");
echo "Email Sent";
?>

script, it redirects well and shows me that it is sent but when i check my mail, i don't see it. I already hosted the site and checked the codes online but they don't work. Please what am I doing wrong

  • Possible duplicate of [PHP mail form doesn't complete sending e-mail](https://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail) – Qirel Jun 25 '17 at 10:34

1 Answers1

0

I had similar problem on one of my website. Later i fugured out that my host doesnt give me permission to use send mail. I tried sending emails by using smtp. Try using Mail.php. Here is the tutorial link. https://www.lifewire.com/send-email-from-php-script-using-smtp-authentication-and-ssl-1171197

I am sure it will work.

Nagesh Katna
  • 679
  • 2
  • 7
  • 27