Solved

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

Posted on 2004-04-16
6
2,360 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Session migration 1 101
method inner class 6 81
String format issue 13 90
iterator example remove 8 74
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
With more and more people tethered to the internet, advertisers can reach you in new and creative ways. Push notifications on your smartphone, customized advertisements based on your previous searches, and email inboxes filled with promotional pitch…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

930 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

12 Experts available now in Live!

Get 1:1 Help Now