- Please edit your post to use [c ode] tags.
- 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.
Why not using Google or Gmail?
Though this code worked for many times in this servlet. But is not working now. I do not know what is wrong with this code
Because you don't own those resources and up-time or serviceability is not guaranteed. Also because running your own mailserver is easy to do and free-of-charge, giving you control over how your mail gets handled. If you don't want to learn to do that, rent a Web space from 1&1.com for $1.99 per month and you get ten free mail accounts on that domain.
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.
Well actually it make no difference to me as it is my university project only. And long as when server is on or not is concerned, it always sends an email when used from command line. But creates problems when sent from servlet
There may be nothing wrong with your code, but the Gmail SMTP port may be rejecting your mail. Google limits the number of messages you can send per hour. If you are over-limit, your code works, but Gmail doesn't.
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.
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?
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?
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.
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.
My pie came with a little toothpic holding up this tiny ad:
Gift giving made easy with the permaculture playing cards