File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes Java Mail Send Failed error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail Send Failed error" Watch "Java Mail Send Failed error" New topic
Author

Java Mail Send Failed error

Prakash Vaidyanathan
Greenhorn

Joined: Oct 10, 2003
Posts: 8
I am having the following code for sending mails from java.
import java.util.Properties;
import java.util.Date;
import javax.mail.Session;
import javax.mail.Message;
import javax.mail.Transport;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.InternetAddress;
import java.util.*;
import java.lang.*;
public class javamail{

public javamail(){

}
public void sendEmail (String userName, String passWord, String emailAddy)
{
String host = "208.220.253.27";
String to = emailAddy;
String from = "sap_rms@satyam.com";
String subject = "subjectMessage";
String messageText = "Some yadda, yadda";
boolean sessionDebug = false;
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.transport.protocol", "smtp");
Session session = Session.getDefaultInstance(props, null);
session.setDebug(sessionDebug);
try
{
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new java.util.Date());
msg.setText(messageText);
Transport.send(msg);
} catch (Exception mex)
{
mex.printStackTrace();
}
}

public static void main(String args[])
{
javamail j = new javamail();
try{
j.sendEmail("p","p","chatwithvpat@yahoo.co.in");
}catch(Exception e)
{
System.out.println (e);
}

}
}

But when I am executing I am getting the following error:
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class javax.mail.SendFailedException: 550 5.7.1 Unable to relay for chatwithvpat@yahoo.co.in
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
at javamail.sendEmail(javamail.java:38)
at javamail.main(javamail.java:49)

Can anybody help me in this. What am i doing wrong in this?
Thanks in advance
Regards
Prakash


V.Prakash
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Mail Send Failed error