Link to home
Start Free TrialLog in
Avatar of vikram_1982
vikram_1982

asked on

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

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
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Either that, or you will have to authenticate on that mail server (with your email/password) before you try to send the mail...

Tim
Avatar of vikram_1982
vikram_1982

ASKER

Okay, I have my id and password for this server. How do i include them in the code above??
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

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)"
ASKER CERTIFIED SOLUTION
Avatar of dheerajbhat
dheerajbhat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial