0

I am somewhat new to programming. I have a form that when submitted, sometimes makes it to my email, and sometimes doesn't. My webhost provider is Bluehost. I can't see any errors in my code, but I might be mistaken. I'm thinking that since sometimes it works, and sometimes it doesn't, it must be a lack of reliability of Bluehost's server. Please note that I have the form submission coming from my own email address to my own email address, to prevent it going to my spam folder.

Mail form:

      <form class='contact-form' action='mail.php' method='POST'>
    <input class='form-input' type='text' name='name' placeholder='Full Name' required />
    <input class='form-input' type='email' name='email' placeholder='Email' required />
    <input class='form-input' type='text' name='phone' placeholder='Phone' required />
    <textarea class='form-input' type='text' name='message' rows=5 placeholder='Tell me about your project...' required></textarea>
    <input type='submit' class='cta-btn form-submit' />
  </form>

And here is my PHP code:

      <?php

    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];
    $sender = 'myemailaddress@gmail.com';
    $recipient = 'myemailaddress@gmail.com';
    $subject = 'Web Development Inquiry';
    $mailheader = "From: $sender \r\n";
    $formContent = "Name: $name \n Email: $email \n Phone: $phone \n Message: $message";
    mail($recipient, $subject, $formContent, $mailheader);

  ?>
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • If it works sometimes and you've not changed the parameters/code compared with when its not working then there's nothing wrong with the code, the problem is in the infrastructure - go read your mailserver logs (and consider switching hosting provider). – symcbean Jun 12 '17 at 16:34
  • I will. Thank you! – Austin Chappell Jun 12 '17 at 17:07

0 Answers0