sending mail to yahoo using javamail

hello,

i have a javamail code which able to send mail within my domain (mailserver ) .

but when i try to send mail to any yahoo id then i get following error :--

javax.mail.SendFailedException: Invalid Addresses;

please, anyone help me ; what should i do modification in my existing code for sending mail to yahoomail account.

the code which is working properly for my doamin is:--

import java.util.*;

import java.io.*;

import javax.mail.*;

import javax.mail.internet.*;

import javax.activation.*;

public class SendMailUsage {

public static void main(String[] args) {

// SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!

String to = "gyanendra.ojha@enodata.com";

String from = "gyanendra.ojha@enodata.com";

// SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!

String host = "172.13.2.48";

// Create properties for the Session

Properties props = new Properties();

// If using static Transport.send(),

// need to specify the mail server here

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

// To see what is going on behind the scene

props.put("mail.debug", "false");

// Get a session

Session session = Session.getInstance(props);

try {

// Get a Transport object to send e-mail

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

bus.connect();

Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));

InternetAddress[] address = {new InternetAddress(to)};

msg.setRecipients(Message.RecipientType.TO, address);

msg.setSubject("Test E-Mail through mojax developers");

msg.setSentDate(new Date());

// Set message content and send

setTextContent(msg);

msg.saveChanges();

bus.sendMessage(msg, address);

bus.close();

}

catch (MessagingException mex) {

// Prints all nested (chained) exceptions as well

mex.printStackTrace();

// How to access nested exceptions

while (mex.getNextException() != null) {

// Get next exception in chain

Exception ex = mex.getNextException();

ex.printStackTrace();

if (!(ex instanceof MessagingException)) break;

else mex = (MessagingException)ex;

}

}

}

// A simple, single-part text/plain e-mail.

public static void setTextContent(Message msg) throws MessagingException {

// Set message content

String mytxt = "this mail is generated by java";

msg.setText(mytxt);

// Alternate form

msg.setContent(mytxt, "text/plain");

}

} //End of class

[2641 byte] By [gyan_softa] at [2007-11-27 6:02:17]
# 1
Turn on session debugging to get the protocol trace. Your mail serveris probably saying more about why the send failed than what you'veincluded here.Then read the FAQ for likely problems.
bshannona at 2007-7-12 16:43:29 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...