I would suggest that you test sending of e-mail in a plain old Java application first, like a small command-line program which does just that and nothing else. Tomcat and Servlets aren't really easy to use for basic testing.
And make sure that your setup agrees with the assumptions that I see from your post:
1. You are running an SMTP server on the same computer where the code is running.
2. It is listening at port 25 (which is the default port for SMTP).
3. It doesn't require authentication.
4. It is configured so that it can relay e-mails which claim to come from a different domain (gmail.com in your case).
You should also become conversant with the administrative functions of that SMTP server, so that you can tell whether it has delivered an e-mail successfully. Or if it isn't your server, you should enlist the help of its administrator.
sam wootton
Ranch Hand
Joined: Apr 16, 2011
Posts: 48
posted
0
[Many thanks for your help.
I think the problem could be my local host sending. I thought i could just use googles smtp server. I did used to run postfix... but it was such a pain to administer, i ditched it.
So you cant send email from java, without the ocal machine running an SMTP server?
You didn't get this from the JavaMail FAQ, did you? Because there's no such property in JavaMail.
There's nothing wrong with using non-existent properties, in the sense that they don't cause the program to break. But it's unhelpful to future maintainers of the code because it gives them extra work to find out that they do nothing. Likewise it's unhelpful to post such code on the web because then unwary students will copy the code elsewhere, compounding the problem.
sam wootton
Ranch Hand
Joined: Apr 16, 2011
Posts: 48
posted
0
Ah thanks Paul Clapham, no i didnt. tbh, it was a mix of googling / forums / mail API reading. I started looking prior to reading your previous response.
Many thanks for your help, much appreciated!
Out of interest - how safe is storing my email pwd as compiled code, on tomcat?
I'm not that happy with it, or am i just paranoid?
Regards, Sam
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
Depends - do you trust your sys admins? If not, I suggest to get hosting elsewhere.
sam wootton
Ranch Hand
Joined: Apr 16, 2011
Posts: 48
posted
0
Tim Moores
well, currently its just running locally (on Opensuse) - so i trust me.
the client-side is actually a swing desktop application, and i guess in the future it would have to use either the chosen hosts mx servers, or my own running next to tomcat. But thats a long way off (and this is only a peronsal project, so whether i ever get to that point is in question).
thanks again for your help.
I more wondered if it was possibleto hack a servlet to get info like that.
Regards, Sam
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
If you somehow obtain physical access to the servlet's class/jar file then it's easy to decompile it and retrieve such information. But I'd argue that once someone has access to those files, and is bent on causing trouble, you have much bigger things to worry about.
In general, you should keep the connection details out of the Java code, maybe in a properties file, just like you'd do for DB and logging properties.