I'll get straight to the point, here's how I've coded my mailform:

<html>
<body>

<?php
  $email = $_REQUEST['email'];
  $subject = "Contact Us Query";
  $message = $_REQUEST['message'];
  $message = stripslashes($message);
  mail("myemail@msn.com", "$subject",
  $message, "From:" . $email);
  header("Location:success.php");
?>
</body>
</html>

My problem is that although the emails get sent, what happens is that they all go to my junk mail rather than inbox. Can I possibly alter the code some way so that the mails dont get recognised as junk and go to my inbox instead? Or something I can do in my hotmail inbox perhaps?

Cheers in advance.

Recommended Answers

All 4 Replies

I had a similar issue, but it had to do with headers, and yours look alright. Easiest fix probably would be to go to your hotmail account and add your "from" email address to a "safe sender" list or whatever hotmail's equivalent of that is.

Hmm but what do you suggest the email is which I'm supposed to put in the "safe" list. Since my contact form takes in an email from the user which it sends me the message, the email is different each time depending on the user.

Well, I don't know much about your site, so I can't say for sure what the best solution would be. For starters, is your site personal (blog, picture sharing, etc) or for some professional/business use (particularly, do you handle financial information?) Also, is your site public or private (do they login)? I ask all that to say this: If your site is personal and private and you don't have an overwhelming amount of traffic, most likely the easiest fix is to add people to a safe sender's list. If your site is public, get's a lot of traffic, or is for professional use, that may not be practical and therefore it may be better to edit your coding, but as I'm still learning myself, I wouldn't feel comfortable saying anything beyond what I already have about the headers. Good thing is there are a lot of people more advanced than me here XD.

Actually found a fix to it myself. I'll post it here for other people that might have had similar problems:

<html>
<body>

<?php
  $email = "someone@example.com"; //mark this as safe in hotmail
  $subject = "Contact Us Query";
  $message = "Sent by: " . $_REQUEST['email'] . "\n\n" . $_REQUEST['message']; //Their entered email followed by their message
  $message = stripslashes($message);
  mail("myemail@msn.com", "$subject",
  $message, "From:" . $email);
  header("Location:success.php");
?>

</body>
</html>

So you are given the email which the user enters within the message, but the message is sent by the arbitrary "someone@example.com" which you can mark as safe in your hotmail so all future messages from the email address "someone@example.com" will go to your inbox as they are considered safe.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.