user3580893
user3580893

Reputation: 1

PHP - e-mail being sent to junk on Hotmail

i'm trying to send e-mail using the function mail().

But my email is being sent to junk, and it works perfectly on gmail, what am i doing wrong?

<?php
if(isset($_POST['submit'])){
    $name = $_POST["name"];
    $name .= " ";
    $from = $_POST['from'];
    $subject = $_POST["subject"];
    $message = $_POST["message"];;
    $to = $_POST["to"];
    mail($to, $subject, $message, "from: $name \n $from \n");
    echo $name;
}
?>

<form method="POST">
    <input type="text" placeholder="from" name="from" />
    <input type="text" placeholder="to" name="to" />
    <input type="text" placeholder="name" name="name" />
    <input type="text" placeholder="Subject" name="subject" />
    <textarea type="text" placeholder="Message" name="message"></textarea>
    <input name="submit" type="submit" />
</form>

Upvotes: 0

Views: 111

Answers (4)

Bartłomiej Wach
Bartłomiej Wach

Reputation: 1986

Another thing than using different php libraries, there is also the matter of whiletilsts/blacklists which are lists of domains/ips which mail hosting companies use to quickly distingquish spam from proper mail so they sometimes require you to send some kind of email from admin@domain... to the moderator to prove you're not a spam bot, try checking this for hotmail.

You might want to read: http://smallbusiness.chron.com/domain-whitelisted-hotmail-46827.html

Upvotes: 0

Sherlock
Sherlock

Reputation: 7597

One of the reasons Hotmail moves your mail to spam, is because you let the user enter the 'from' address. If the domain from which the mail is sent doesn't coincide with the from address in the header, the mail is seen as spam. Some servers reject the mail altogether.

Using PHPMailer or SwiftMailer sure helps with setting the right headers, but you should never send mails from other domains than your own.

Upvotes: 0

Reece
Reece

Reputation: 396

The problem could be that the domain name in your $from field doesn't match the server that the email is being sent from. The IP address that you are sending from could also be on the spam blacklist for the email client provider you are using.

There are some other guidelines that can affect how email clients will detect your email as junk, such as whitespace in the header fields, missing Reply-To and Return-Path headers etc.

Upvotes: 4

hellosheikh
hellosheikh

Reputation: 3015

use smtp for sending an email then it will not go in junk

http://www.mendoweb.be/blog/php-send-mail-smtp-server-authentication-required/

Upvotes: -2

Related Questions