Solved

php mail() in Hotmail junk, please help

Posted on 2012-03-31
4
1,125 Views
Last Modified: 2012-03-31
Hi,
It´s been a while since i´m trying to get out of the hotmail junk.
I have searched in a lot of places but i haven´t found nothing that works, i´ll be much grateful if someone helps me. I need to lunch this site today 00:00.
So far i have this:
        $mail_envia = "someone@hotmail.com";
      $mail_admin = "email@mydomain.com";
      $assunto = "Text";
      $assunto = "=?UTF-8?B?".base64_encode($assunto)."?=";
      
      $headers = "From: mydomain <$mail_admin>\r\n";
      $headers .= "Bcc: <$mail_envia>\r\n";
      $headers .= "Reply-To: $mail_admin\r\n";
      $headers .= "X-Sender: <$mail_admin>\r\n";
      $headers .= "Return-Path: <$mail_admin>\r\n";
      $headers .= "MIME-Version: 1.0\r\n";
      $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
      $headers .= "Content-Transfer-Encoding: 7bit\r\n";
      $headers .= "Date: ".date("D, d M Y H:i:s") . " UT\r\n";
      $headers .= "Message-ID: <".sha1(microtime())."@mydomain.com>\r\n";
      $headers .= "X-Mailer: PHP5\r\n";
      $headers .= "X-Priority: 3\r\n";
      
      $mensagem = "<table cellspacing='0' cellpadding='0' border='0' bgcolor='#f8eed8' width='756px'>
                              <tr>
                                    <td width='756px' height='100px' colspan='2' align='center'>
                                          <font size='5px'>
                                                TEXT
                                          </font>
                                    </td>
                              </tr>
                              <tr>
                                    <td width='196px' height='446px' align='center'>
                                          <font size='6px' color='#7e6845'>
                                                <b>
                                                      TEXT
                                                </b>
                                          </font>
                                    </td>
                              </tr>
                        </table>
                        <table cellspacing='0' cellpadding='0' border='0' width='756px'>
                              <tr>
                                    <td align='center' height='50px' width='756px'>
                                          TEXT
                                    </td>
                              </tr>
                        </table>";
      if(mail(null,$assunto,$mensagem,$headers,"-f $mail_admin")) {
            #Do something;
      } else {
            #Do something;
      }
0
Comment
Question by:pep477
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 37791964
The only thing that works with Hotmail is your reputation for your email address.  Nothing else will get you delivered to the Inbox.  They are more concerned with blocking spam than with delivering email... since they get much more spam than legitimate email.  Even a simple plain text email from many addresses will be marked suspicious and anything that is web-server generated almost always is.  Here is their troubleshooting page:  http://mail.live.com/mail/troubleshooting.aspx

I just noticed that you put a 'null' for the 'to' address in you post.  ??

I would eliminate these lines:
$headers .= "Date: ".date("D, d M Y H:i:s") . " UT\r\n";
      $headers .= "Message-ID: <".sha1(microtime())."@mydomain.com>\r\n";
      $headers .= "X-Mailer: PHP5\r\n";
      $headers .= "X-Priority: 3\r\n";

Open in new window

Date-time and message id are set by the SMTP server and you may duplicating them.
0
 
LVL 7

Expert Comment

by:designatedinitializer
ID: 37791970
I would try to send that email through SMTP.
First create a proper email account on your server, then use a PHP library with SMTP support, like a class I use called XMimeMail.
You can find it online, and it is pretty straightforward to use.

But be prepared to face the fact that Hotmail may still dump your emails to the junk folder.
You will have to advise the receivers that your emails may end up in the junk folder, and they should put your sender email address in the list of known senders. That's the only way to guarantee it won't happen.
0
 

Author Closing Comment

by:pep477
ID: 37791997
Thank you for your replie, i was waiting for something like that, i knew it was strange after all my research nobody could do that with the mail() function of php, but thanks.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 37792041
For what it's worth, this is my PHP Email demo using the mail() function.  I have no trouble sending to my Hotmail account with it but the last time, it marked it as 'Suspicious'.

<?php
error_reporting(E_ALL);
ini_set('display_errors','On');

# some settings of POST vars
if (!isset($_POST['send']))  $send = ''; else $send = $_POST['send'];
if (!isset($_POST['toText'])) $toText = ''; else $toText = $_POST['toText'];
if (!isset($_POST['ccText'])) $ccText = ''; else $ccText = $_POST['ccText'];
if (!isset($_POST['subjectText'])) $subjectText = ''; else $subjectText = $_POST['subjectText'];
if (!isset($_POST['msgText'])) $msgText = ''; else $msgText = $_POST['msgText'];
if (!isset($_POST['ccText'])) $ccText = ''; else $ccText = $_POST['ccText'];
if (!isset($_POST['bccText'])) $bccText = ''; else $bccText = $_POST['bccText'];
if (!isset($_POST['nameText'])) $nameText = ''; else $nameText = $_POST['nameText'];
if (!isset($_POST['fromText'])) $fromText = ''; else $fromText = $_POST['fromText'];

if ($send == "") {
    $title="Test Email Page";
    $announce="---";
}
else {
	if($fromText === "") die("No name!");
  $toText="youremail@yourdomain.com";
	$title="Test Email Page";
  $announce="Your Message has been Sent!";
	$header = "From: ".$fromText."\r\n";
//	$header .= "Cc: ".$ccText."\n";
	$header .= "Reply-To : ".$fromText."\r\n";
	$header .= "Return-Path : ".$fromText."\r\n";
	$header .= "X-Mailer: PHP\r\n";
	$header .= "MIME-Version: 1.0\r\n";
	$header .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
//	ini_set(sendmail_from,$fromText);  
	mail($toText, $subjectText, $msgText, $header, '-f'.$fromText);
//	ini_restore(sendmail_from);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo($title)?></title>
<style type="text/css">
<!-- 
A:link { color: #999999; }
A:visited { color: #999999; }
A:hover {color: #0099ff;}
-->
</style>
<script type="text/javascript">
<!--
function check()
{
var at=document.getElementById("fromText").value.indexOf("@");
var eml=document.getElementById("fromText").value;
var nam=document.getElementById("nameText").value;
var alerttxt="";
var submitOK="true";

if (eml.length < 5 || at == -1)
    {
    alerttxt=alerttxt+"Please enter a valid e-mail address!\r\n";
    submitOK="false"
    //return false;
    }
if (nam.length < 3)
    {
    alerttxt=alerttxt+"Please enter your name.\r\n";
    submitOK="false"
    //return false;
    }
if (submitOK=="false")
    {
    alert(alerttxt);
    return false;
    }

}
// -->
</script>
</head>

<body bgcolor="#ddeedd">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" summary="" width="580">
<tr><td align="center">

<?php
if ($send != "") {
   	echo ("To: ".$toText."<br>\r\nSubject: ".$subjectText."<br>\r\n".$msgText."<br>\r\n".$header);
		}
?>

<p><b><font color="#000000" size="5">Test Email</font></b></p>
<font size="4" color="#000000">

<form method="POST" action="Email.php" onsubmit="return check();">
    <p><font size="3"><b>Name: <input type="text" name="nameText" id="nameText" size="46"></b></font></p>
    <p><font size="3"><b>Email: <input type="text" name="fromText" id="fromText" size="46"></b></font></p>
    <input type="hidden" name="subjectText" value="Web Mail">
    <p><font face="Arial" size="3"><b>Message Text:</b></font></p>
    <p><font face="Arial" size="3"><b><textarea rows="6" name="msgText" cols="60"></textarea></b></font></p>
    <p><font size="3"><b><input type="submit" value="Send" name="send" style="font-family: Arial; font-size: 12pt; font-weight: bold"></b></font></p>
    <input type="hidden" name="state" value="1">
  </form>
  <b><font face="Arial" size="4" color="#e00000"><?php echo($announce)?></font></b><br><br>

</font>
</td></tr>
</table> 
</div>


</body>
</html>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The goal of the tutorial is to teach the user how to block contacts and manage the block contact list.
The goal of the tutorial is to teach the user how to make an account for Skype and brief over view of all the options. There are the parts in this series.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now