• Post Reply Bookmark Topic Watch Topic
  • New Topic

java mail  RSS feed

Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started learning about java mail.
I am trying with this code

<%@ page import="java.util.Properties,javax.mail.*,javax.mail.internet.*"%>

<% String smtpHost = "crisdev";
String from = "mmalviya@crsl.com";
String to = "mmalviya@crsl.com";

// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", smtpHost);

// Get session
Session s =
Session.getDefaultInstance(props, null);

// Define message

MimeMessage message = new MimeMessage(s);
message.setFrom(new InternetAddress(from));
new InternetAddress(to));
message.setSubject("Hello, JDC");
message.setText("Welcome to the JDC");
// Send message

But I am getting this exception.

javax.servlet.ServletException: Sending failed;
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 550 5.7.1 Unable to relay for mmalviya@crsl.com


Please suggest me with appropriate solution and good link for learning java mail.
Mahesh Malviya
Posts: 42975
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your mail server called "crisdev" set up to allow email relaying? These days, most servers don't allow that, in order to reduce spam. You might need to set it up so that it recognizes @crsl.com email adresses as its "own" addresses (which it seems not to do now).
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!