0

I have a little form where the website visitor can enter his email to subscribe for a newsletter. My goal is to make the form send me an email with the information he entered.

My problem is every single e-mail I get goes straight to the Junk folder.

HTML:

<form class="subscribe" action="subscribe.php" method="POST">
    <input type="text" name="subscribefield" required="true" placeholder="Awe" />
    <button type="submit"><i class="fa fa-paper-plane fa-lg" aria-hidden="true"></i>
    </button>
</form>

PHP:

<?php

  $email = $_POST['subscribefield'];
  $to = "test@live.com";
  $subject = "new sub";
  $body = $email;

  mail($to, $subject, $body);

  echo "your mail was sent";
?>
jotik
  • 17,044
  • 13
  • 58
  • 123
Kevin
  • 930
  • 3
  • 13
  • 34
  • 1
    This very likely has nothing to do with your HTML or PHP code, but is an issue with the junk e-mail filter on your e-mail server, which (incorrectly) filters these messages as junk. – jotik Jun 07 '16 at 08:42
  • 1
    Use a library like PHPMailer for sending e-mails. Otherwise, you need to set all the mail headers correct by yourself and you're likely to make a mistake there → it goes to the junk folder. – ssc-hrep3 Jun 07 '16 at 08:47

1 Answers1

4

If you are using a shared server than probably the score for that server is bad. If you are using your own server probably it's neutral but sometimes will go to spam because the server does not have a good reputation and depends how each email provider see that email.

Best solution I see it's to integrate a mailing service. In this way they promise that emails will not go to spam. I don't know how many emails you are sending / month. There are some that offer free email / month. Depends on volume. For example:

  1. SendGrid - 12.000 free emails / month and they have official PHP library . Tested no problem with spam.
  2. MailGun - 10.000 free emails / month. Did not test this one but it's from rackspace
  3. Mandrill - no free emails, part of mailchimp. Tested no problem with spam.
  4. Amazon SES - 62.000 free emails / month for first year if you use free tier. Tested no problem with spam.
Daniel Dudas
  • 2,972
  • 3
  • 27
  • 39