File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes Relay Access Denied....(HELP..!!!!!) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Relay Access Denied....(HELP..!!!!!)" Watch "Relay Access Denied....(HELP..!!!!!)" New topic

Relay Access Denied....(HELP..!!!!!)

Jignesh Kakkad
Ranch Hand

Joined: Apr 09, 2004
Posts: 49
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;

public class T

public static void main(String[] args)

Properties props = new Properties();
props.put("", "");
//props.put("", "");
//props.put("", "");

Session mailConnection = Session.getInstance(props, null);

Address bill = new InternetAddress("",true);
Address elliotte = new InternetAddress("",true);
Message msg = new MimeMessage(mailConnection);

msg.setRecipient(Message.RecipientType.BCC, elliotte);
msg.setSubject("You must comply.");
msg.setContent("Resistance is futile. You will be assimilated!",



catch(AddressException a)
catch (SendFailedException e)
catch (MessagingException e)



we get invalid address and relay Access Denied Exception....
Please Help Us...


Jignesh Kakkad, Cellent Technologies Pvt, Nariman Point, Mumbai
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

A few points (sorry to be critical): Why are you explicitly using strict validation of email addresses when new InternetAddress(java.lang.String address) does this by default? And empty catch blocks will always give you headaches.

Aside from that, both:

are perfectly valid RFC822 email addresses, so neither of these lines should be giving you an AddressException (are you sure that's what you are getting?)

"Access Denied" exceptions will be something to do with the connection to the SMTP server. Does "" need any authentication/authorization? Are you behind a proxy or firewall?

Here's a list of things I always tell people to do when they have problems with JavaMail:
  • Enable SMTP debugging, so you can see the actual SMTP traffic.
  • Speak to the SMTP server admin and try to telnet to the server. Both are very quick ways to test whether you actually can access it in the way you want to. Any glitches/restrictions can be ironed out here before you have written a line of Java.
  • Write Transport and Connection Handlers which log activity properly (good to help you debug problems, and essential if you want the application to be supported by someone else)
  • Read the JavaMail FAQ's (if you haven't already - this will alert you to common issues people encounter. People are forever misunderstanding the implications of having a proxy server involved in the process for instance.
  • Develop and test you JavaMail code seperate from your SMTP server. Use Dumbster (or James if you must) to check your code is doing what you want it to, and generating the proper SMTP messages. That way you are not mixing debuging code with debugging infrastructure which makes the process easier in the long run.

  • JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Jignesh Kakkad
    Ranch Hand

    Joined: Apr 09, 2004
    Posts: 49
    Thanx For replying me
    Yes i know what i am getting this is true..
    I am getting exception like invalid address and relay access denied..!!!

    And do u what are other free SMTP service provider..?

    Jignesh Kakkad
    I agree. Here's the link:
    subject: Relay Access Denied....(HELP..!!!!!)
    It's not a secret anymore!