File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Mail Send Failed error" Watch "Java Mail Send Failed error" New topic

Java Mail Send Failed error

Prakash Vaidyanathan

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 = "";
String to = emailAddy;
String from = "";
String subject = "subjectMessage";
String messageText = "Some yadda, yadda";
boolean sessionDebug = false;
Properties props = System.getProperties();
props.put("", host);
props.put("mail.transport.protocol", "smtp");
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSentDate(new java.util.Date());
} catch (Exception mex)

public static void main(String args[])
javamail j = new javamail();
}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
at javax.mail.Transport.send0(
at javax.mail.Transport.send(
at javamail.sendEmail(
at javamail.main(

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

I agree. Here's the link:
subject: Java Mail Send Failed error
jQuery in Action, 3rd edition