Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending an email from jsp page

 
Deparis Momo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I created and hosted a JEE application and I have a jsp page named contact.jsp from which a user can send me an email. I can use "mailto" link for that but I want to send the mail from my jsp page.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65340
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you don't.

You want to submit to a servlet that will use the JavaMail API to send the email. Java code has no place in a JSP which should be a view only.
 
Deparis Momo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,I know how to send an email with the JavaMail API:



This code send the message from my SMTP server to the user address mail for example, but I want to do the opposite i.e sending the message from the user to my SMTP srver.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deparis Momo wrote:... but I want to do the opposite i.e sending the message from the user to my SMTP srver.


But it doesn't make sense for you to send a message from somebody else. You have to wait for them to send the message. And for that, the mailto link is the normal way to enable them to send a message. So, what do you want to do which a mailto link doesn't already do?
 
Deparis Momo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Find in this link an example of what I want to do. There is an form which an user can fill and send his message:

Example of sending an email from the website

Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you create an HTML form that submits to a servlet that calls your above utility method. Doesn't sound too hard.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just bear in mind that the example you linked to doesn't exactly allow the user to send you an e-mail. It allows the user to input certain information, including an e-mail address, and then the server does something with that information. It's possible that it puts the information into a database and then a responsible person will deal with new rows in that database, or it's possible that it sends an e-mail to that responsible person. In the latter case it's most likely that the e-mail comes from the system; trying to send e-mails on behalf of other people is a tricky business and it will often look like spam to mail servers.
 
Deparis Momo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok now I understand. Thank you to all.

Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic