Mail received by Yahoo, but not Hotmail. please help see my code

I am using the following code to send email to my Hotmail account.

Properties props = System.getProperties();

props.put("mail.smtp.host", "localhost");

Session session = Session.getDefaultInstance(props, null);

Transport transport = session.getTransport("smtp");

transport.connect();

String toAddress="myid@hotmail.com";

MimeMessage message = new MimeMessage(session);

message.setFrom(new InternetAddress("test@mydomain.com"));

message.addRecipient(Message.RecipientType.TO,

new InternetAddress(toAddress));

message.setSubject("test");

message.setContent("test");

message.saveChanges();

transport.sendMessage(message, message.getAllRecipients());

--

For the code above, Hotmail could not receive the mail.

If I change the toAddress to my Yahoo account, Yahoo can receive the email.

However, If I use telnet to send mail to my Hotmail account from the same machine, it works.

> telnet localhost 25

> HELO ..

> MAIL FROM:

> RCPT TO:

...

I could not figure out what is the difference between Yahoo and Hotmail email. Can anyone help me?

Thank you in advance.

Dave

[1238 byte] By [javaonedavea] at [2007-11-27 6:48:52]
# 1

I've heard rumors, which I haven't verified, that HotMail is rejecting

messages that have a JavaMail-generated Message-ID because

it thinks the message is spam. Apparently too many JavaMail users

are actually spammers. :-(

In the message you send using telnet, try pasting in a JavaMail style

Message-ID header and see if that makes a difference. Or, try

subclassing MimeMessage and override the updateMessageId

method to generate a different kind of ID.

Also, look in your spam mailbox on HotMail, if they support that.

bshannona at 2007-7-12 18:22:22 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
hisend me all the ful codes to send emails and receive all messages from yahooplease tell how to implement that oneplz send to kprathish@miragelogic.comthanks in advance
prasanit2005a at 2007-7-12 18:22:22 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
It's not a matter of code, it's a matter of configuration.The JavaMail FAQ tells you how to configure accessto Yahoo mail.
bshannona at 2007-7-12 18:22:22 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
this this prathishcan u plz send me the code for accessing the yahoo mailto my mail idkprathish@miragelogic.comthnks in advance
prasanit2005a at 2007-7-12 18:22:22 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
The code you need is in the sample programs that are includedin the JavaMail download bundle available from http://java.sun.com/products/javamail. Please read the FAQwhile you're there.
bshannona at 2007-7-12 18:22:22 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

Extend MimeMessage for change header Message-ID

/**

* Objet MimeMessage 閠endu pour changer l'ent阾e Message-ID

*/

private final static class MyMimeMessage extends MimeMessage

{

protected Session session;

/**

* Constructeur!

*

* @param _sessionjavax.mail.Session

*/

protected MyMimeMessage(Session _session)

{

super(_session);

this.session = _session;

}

// code other constructor that needed!

/**

* Modification du Message-ID ent阾e (appeler par updateHeaders!)

*/

protected void updateMessageID() throws MessagingException

{

setHeader("Message-ID", getMyMessageID(session));

setHeader("X-Mailer", "EMail_2.0"); // ajout du mailer...

}

/**

* Retourne un unique Message-ID.

*/

private static String getMyMessageID(Session _session)

{

InternetAddress localAddress = InternetAddress.getLocalAddress(_session);

String address = (localAddress != null) ? localAddress.getAddress() : "user@localhost";

Long id = new Long(0);

double d = java.lang.Math.random();

id = new Long((long) (d * Long.MAX_VALUE));

StringBuffer buffer = new StringBuffer();

buffer.append(id);

buffer.append('.');

buffer.append(System.currentTimeMillis());

buffer.append('.');

buffer.append("EMail.");

buffer.append(address);

return buffer.toString();

}

} // fin de classe

alterna at 2007-7-12 18:22:22 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...