• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

email sending code is not working in servlet

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note that you should never use GET and POST interchangeably, no matter how many servlet tutorials erroneously show that.

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
 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Roger Sterling
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Roger Sterling
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With debug statement I tried couple of times and it worked both the times. What is magic related to this Debug statement?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I worked again with this session.setDebug(true);
Why did it run please explain???
 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
waqas imtiaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic