Solved

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

Posted on 2004-04-16
6
2,356 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
A procedure for exporting installed hotfix details of remote computers using powershell
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now