wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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 = "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);
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 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

It is sorta covered in the JavaRanch Style Guide.
subject: Java Mail Send Failed error
Similar Threads
java mail
JSP using javamail
Error while running a simple java mail application
JavaMail Exception.......HELP!!
please clear me