• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending E-Mail using JSP  RSS feed

 
AshishcKumar singh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

I need to send an e-mail to the e-mail ID of a user.
Can anyone please help me out?.. I've no idea about it at all!

And also smtp address of some mailer deamon if you know of.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
E-mail ID? You mean, like somebody's e-mail address? You would use JavaMail for that.

Hopefully you would put code like this into a servlet rather than a JSP, but it's possible to put Java code into a JSP scriptlet if you want to ignore all the progress made in the web application field for the last five years.

Anyway, wherever you put the code you would use JavaMail to send e-mail messages. The JavaMail download includes examples of how to do that. Also, many servlet containers allow you to configure a JavaMail session so that your code can get it via JNDI, rather than having to hard-code the name of your SMTP server and so on into your application.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An excellent tuorial with many code examples is at http://java.sun.com/developer/onlineTraining/JavaMail/contents.html

In this day and age of spam there are no publicly usable email servers any more. You will need to use your own. It's no big deal to fire up a server like Apache James (which is even written in Java, so you could embed it on your application).
 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Just run the bellow example.
http://www.forums.hscripts.com/viewtopic.php?f=18&t=3048

Regards,
Vinoth.
[ December 20, 2008: Message edited by: vinoth thirunavukarasu ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.forums.hscripts.com/viewtopic.php?f=18&t=3048

Using classes in the sun.* package is bad practice; don't do that.
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:

Using classes in the sun.* package is bad practice; don't do that.

Ever. Your code may work right now, but even a small update of the JRE / JDK can break your code if Sun decides to rename or delete the class / method you're using. Since it's not in the public API they are free to do so.

If you want it to be simple, use Apache Commons Email instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!