- Don't use gmail / google as your outbound mail server.
- Setup your own mailserver for outbound processing or use your University's mailserver or rent a $1.99 Web account from 1&1.com and use it's mail service.
You should turn on JavaMail debugging so that you get a lot more output about what's (not) happening: http://www.oracle.com/technetwork/java/faq-135477.html#debug
Using Gmail/Google is a bad idea because you do not have control over when your mail gets delivered or when the service changes or who has access to the content of your mail to include the email Id of the person you are sending to.
waqas imtiaz wrote:I do not know what is wrong with this code
That is why I suggested using the dedug option; have you done that yet? If not, start with that. Don't get distracted by a discussion of Gmail vs. not Gmail. That may or may not be the problem, but if the mail code has worked for you before, chances are it's not. But using the debug option is highly likely to help you in debugging.
Ulf Dittmer wrote:The point of the debug option is that it produces LOTS of output that tells you what's going on, particularly if something goes wrong. Did you see that output in the log files?
I actually saw all of those outputs. But nothing is wrong and program worked every time with debug statement. Why is so?
Ulf Dittmer wrote:You shouldn't be surprised that your code works Of course, we can't speculate why it's not failing now, because we have no idea why it was failing before. So I guess the lesson is to keep the debug option turned on, so that if things fail again, you'll have the debug output to look into.
Yeh you are right. Thank you all of the guys for helping.