Solved

sun.net.smtp.SmtpProtocolException: 550 error.. Have no idea what it is...

Posted on 2004-04-16
6
2,367 Views
Last Modified: 2012-08-14
Hello,

I am writing a small scriptlet in jsp to send a mail to a specified email address. Here is the code...

<%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>
<%
 String from="myname@mydomain.com";
 String to="recipient@recipientdomain.com";
 try{
     SmtpClient client = new SmtpClient("203.197.175.3"); //This is the SMTP server address
     client.from(from);
     client.to(to);
     PrintStream message = client.startMessage();
     message.println("To: " + to);
     message.println("Subject:  Sending email from JSP!");
     message.println("This was sent from a JSP page!");
     message.println();
     message.println("Cool beans! :-)");
     message.println();    
     message.println();
     client.closeServer();
  }
  catch (IOException e){      
     System.out.println("ERROR SENDING EMAIL:"+e);
  }
%>


I am getting the following error:

ERROR SENDING EMAIL:sun.net.smtp.SmtpProtocolException: 550 5.7.1 <recipient@recipientdomain.com>... Relaying denied. IP name lookup failed [192.168.3.217]  

Note: 192.168.3.217 is my IP address behind the LAN.

Plz help me out.
Vikram.V
0
Comment
Question by:vikram_1982
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 10840805
You are trying to force your email address as being something other than your address...

This is called "relaying", and was the biggest cause of spam...  Therefore, almost all public mail servers do not allow it (and those that do often get added to spam-blacklists)...

You will have to send the email from a mail server set up on your machine...

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10840809
Either that, or you will have to authenticate on that mail server (with your email/password) before you try to send the mail...

Tim
0
 
LVL 2

Author Comment

by:vikram_1982
ID: 10840920
Okay, I have my id and password for this server. How do i include them in the code above??
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:dheerajbhat
ID: 10890445
Hi,
   Add the following line of code as shown below


     SmtpClient client = new SmtpClient("203.197.175.3"); //This is the SMTP server address
/*Add this code*/
      client.sendServer("VRFY youruserid");
/*till here*/
     client.from(from);

  It might still decline if some IP matching is done to validate relaying.And your
   client.from(from) statement may require your actual mail address(on the same server to which you are sending).

  Hope this solves your problem

Regards
Dheeraj Bhat

0
 
LVL 2

Author Comment

by:vikram_1982
ID: 10898863
Dheeraj,

I tried what u  told me and this is the error message i got.. any idea??

"ERROR SENDING EMAIL:sun.net.smtp.SmtpProtocolException: 252 2.5.2 Cannot VRFY user; try RCPT to attempt delivery (or try finger)"
0
 
LVL 1

Accepted Solution

by:
dheerajbhat earned 100 total points
ID: 10937535
Hi,
    It means that the userid you are using is not correct.Are you sure about that on the server you are trying.For example if my mailaddress is dheerajbhat@xyz.com my id might be dbhat.

looks like you dont have an id on that server.To confirm that,try to capture the server response by adding
client.sendServer("VRFY youruserid");
/*Add these lines*/
String response = client.getResponseString();
System.out.println("THE RESPONSE IS:"+response );
/*Till here*/
 client.from(from);

  If you get a response like 550,it means your userid is not verified.Please check that.

Best of luck
REgards
Dheeraj Bhat


0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
some methods private some are not 8 223
maven webservice projet error 6 80
Using Tomcat as raspberry pi java app server 13 232
going to wrong jsp page 2 50
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In order to fulfill our mission of inspiring learning in the technology community, Experts Exchange is launching a Course of the Month program. Premium and Team Account members will have access to one course per month as a part of their membership, …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question