File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes how to send a mail from a jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "how to send a mail from a jsp?" Watch "how to send a mail from a jsp?" New topic

how to send a mail from a jsp?

Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131

we tried the following code. its not working.

has any one of you tried this before?


Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

its not working

What exception are you seeing? Where do you define your SMTP server details?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15100

Why are you using the class

Read this:
Why Developers Should Not Write Programs That Call 'sun' Packages

You should use JavaMail instead of using the 'sun' packages.

And just saying "it doesn't work" is not a good way to ask a question; please read this:
How To Ask Questions On Java Ranch

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Dave Salter
Ranch Hand

Joined: Jul 20, 2005
Posts: 293

Here's an article explaining how to use JavaMail.
Anu satya
Ranch Hand

Joined: Mar 17, 2005
Posts: 146

You can refer to my thread at:

the code which i used there is exactly working fine.

Please note, i am uploading a .csv file and sending mail. You can modify that code according to your requirement.

Please note : way2= the "String-type" path where the file to be sent an email is located.

With Regards,
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

Moved to Other Java APIs.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: how to send a mail from a jsp?
It's not a secret anymore!