aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Relay Access Denied....(HELP..!!!!!)" Watch "Relay Access Denied....(HELP..!!!!!)" New topic
Author

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

Jignesh Kakkad
Ranch Hand

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

public class T
{

public static void main(String[] args)
{

Properties props = new Properties();
props.put("mail.smtp.host", "mail.cloud9.net");
//props.put("mail.host", "SMTP.mail.yahoo.com");
//props.put("mail.host", "smtp.blabla.co.om");
try
{

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

Address bill = new InternetAddress("jig2nesh@yahoo.com",true);
Address elliotte = new InternetAddress("jig2nesh@yahoo.com",true);
System.out.println(elliotte);
Message msg = new MimeMessage(mailConnection);

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

Transport.send(msg);

}

catch(AddressException a)
{
}
catch (SendFailedException e)
{
//e.printStackTrace();
//System.out.println((e.getInvalidAddresses()).length);
System.out.println(e);
}
catch (MessagingException e)
{
}

}

}

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

Jignesh


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

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 "mail.cloud9.net" 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..?

    Thanx
    Jignesh Kakkad
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Relay Access Denied....(HELP..!!!!!)