I'm not a mail admin, so I don't know much about this stuff. Basically, I have some of my programs email me results and stuff like that, and it works fine when having them send to my work address, but not to other addresses like my GMail or Yahoo. If I try that, I get message that looks like this:
[root@app1 root]# java BasicMail
IOException with URLConnection or Printwriter: sun.net.smtp.SmtpProtocolException: 550 5.7.1 <myaddress@gmail.com>... Relaying denied. IP name lookup failed [63.127.99.299]
Exception in thread "main" java.lang.NullPointerException
at BasicMail.<init>(BasicMail.java:33)
at BasicMail.main(BasicMail.java:43)
[root@app1 root]#
I'm trying to figure out what this means. I know this same program works on a Windows 2000 machine on the same network, but not on the Red Hat Linux box. In case you want more details, these servers are behind a router in a cabinet at a data center. For the sake of this conversation, say our domain is noobly.com. Our small ISP that provides internet to our office (far from the data center) is still the registrar for our domain, so emails to
me@noobly.com are handled by our ISP, and they handle the DNS for our webserver that's sitting at the data center. Tech support at our ISP wrote me back to say that we need to tell the data center folks to simply create a reverse DNS entry for our IP address (63.127.99.299).
I hope that's all I need, but turnaround time on the ticket I opened might be a while, and my boss wants some of this set up soon! So, why is it that the program below works on a Windows box and not on the Linux box?
Of course I modified it slightly before posting it, but here's the basic idea:
Code:
class BasicMail {
public BasicMail() {
String message= "Here's my message.";
java.net.URL url = null;
java.net.URLConnection conn = null;
java.io.PrintWriter pout = null;
System.setProperty("mail.host", "my.mailhost.com");
try {
url = new java.net.URL ("mailto:myaddress@gmail.com");
} catch (java.net.MalformedURLException e) {
System.err.println("Malformed URL in setting mailtoAddress: " + e);
}
try {
conn = url.openConnection();
pout = new java.io.PrintWriter (conn.getOutputStream(),true);
} catch (java.io.IOException e) {
System.err.println("IOException with URLConnection or Printwriter: " + e);
}
pout.print ("To: My Name\n");
pout.print ("From: Tester\n");
pout.print ("Subject: My subject \n");
pout.print (message+ "\n");
pout.close();
}
public static void main(String [] args) {
BasicMail mailTest = new BasicMail();
}
}