0

If I add a gmail email ID in the email field, it works but when I try to send using yahoo, I don't get the email :(

Any idea why this is happening and how do I fix it?

<?php
  $name    = stripslashes($_POST['name']);
  $email   = stripslashes($_POST['email']);
  $phone   = stripslashes($_POST['phone']);
  $city   = stripslashes($_POST['city']);
  $franchise = $_POST['franchise'];
  $experience = $_POST['experience'];
  $message = stripslashes($_POST['message']);
  $form_message = "Name: $name \nEmail: $email \nPhone: $phone \nCity: $city \nFranchise: $franchise \nExperience: $experience";

if ( $_POST['human'] ) {
  echo 'Tastes Like Spam!'; exit; }
else {
  header( "Location: http://www.example.com/success.php");
  mail("me@example.com", "Contact Us", $form_message, "From: $email" );
}
?>
Elaine Byene
  • 3,868
  • 12
  • 50
  • 96
  • 1
    check your spam – Ravi Mar 19 '17 at 08:36
  • I recommend using http://swiftmailer.org/ . Because `mail` function can be broken depending to server. –  Mar 19 '17 at 08:48
  • I did that already. Tried sending with other non-yahoo mails and it works. – Elaine Byene Mar 19 '17 at 08:48
  • Check whether your SMTP server complies with all the rules of Yahoo. Think of SPF, DKIM, DMARC and reverse lookup, for instance. But most likely it doesn't like you using an email address that doesn't correspond with the domain you're sending from. Mail like that can disappear in a black hole. Here's a link: https://help.yahoo.com/kb/SLN3435.html – KIKO Software Mar 19 '17 at 08:51

1 Answers1

0

You're using a user-submitted from address which means you are forging it, and will thus fail SPF checks. Your messages are also malformed and vulnerable to header injection attacks. Just don't use mail, use a library that protects you from this kind of thing like PJPMailer, that you tagged this question with.

Synchro
  • 35,538
  • 15
  • 81
  • 104