• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending an email from jsp page

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28264
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22789
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28264
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok now I understand. Thank you to all.

Regards
 
reply
    Bookmark Topic Watch Topic
  • New Topic