473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

send mails via jsp/servlets

does any one have a clue as to how to send a mail via jsp/servlets.
Jul 17 '05 #1
3 6928

"mihir" <mi*****@indiatimes.com> wrote in message
news:3a**************************@posting.google.c om...
does any one have a clue as to how to send a mail via jsp/servlets.

Oui... http://java.sun.com/products/javamail/

Download the mail api and here's a little code example of how to do it....

<%
Session session2 = Session.getDefaultInstance(new
java.util.Properties(), null);
Transport transport = session2.getTransport("smtp");
transport.connect /* to a mailserver that can send the mail */
(
mailserver
, "username"
, "password"
);

MimeMessage email = new MimeMessage(session2);
email.setSubject("test");
email.setFrom(new InternetAddress("yo**@address.com", "This is me"));
email.setRecipient
(
Message.RecipientType.TO
, new InternetAddress("tohim/he*@redwood.com", "Your friend")
);

MimeBodyPart body = new MimeBodyPart();
String message = " bla bla bla "; /* The message */

email.setContent(message, "text/plain");

// Commented out for testing
transport.send(email, email.getAllRecipients());
%>

To be honoust... I just typed this in. There might be some mistakes. You can
either use Transport.send (which uses for example default mail on unix) or
connect to a server (which I do in the example) and the use the transport
object to send the mail instread of the static call.

Adieu,

Rein

Jul 17 '05 #2

"mihir" <mi*****@indiatimes.com> wrote in message
news:3a**************************@posting.google.c om...
does any one have a clue as to how to send a mail via jsp/servlets.

Oui... http://java.sun.com/products/javamail/

Download the mail api and here's a little code example of how to do it....

<%
Session session2 = Session.getDefaultInstance(new
java.util.Properties(), null);
Transport transport = session2.getTransport("smtp");
transport.connect /* to a mailserver that can send the mail */
(
mailserver
, "username"
, "password"
);

MimeMessage email = new MimeMessage(session2);
email.setSubject("test");
email.setFrom(new InternetAddress("yo**@address.com", "This is me"));
email.setRecipient
(
Message.RecipientType.TO
, new InternetAddress("tohim/he*@redwood.com", "Your friend")
);

MimeBodyPart body = new MimeBodyPart();
String message = " bla bla bla "; /* The message */

email.setContent(message, "text/plain");

// Commented out for testing
transport.send(email, email.getAllRecipients());
%>

To be honoust... I just typed this in. There might be some mistakes. You can
either use Transport.send (which uses for example default mail on unix) or
connect to a server (which I do in the example) and the use the transport
object to send the mail instread of the static call.

Adieu,

Rein

Jul 17 '05 #3
Here is some example code :

http://www.javapractices.com/Topic144.cjp

mihir wrote:
does any one have a clue as to how to send a mail via jsp/servlets.


Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: CK | last post by:
Hi All, Can i know that, is it possible for me to develop a website offline, and using CDO. How i can know that, the script I wrote at offline and run at localhost will work when I host it on the...
2
by: tomtailor | last post by:
Hello! I'm migrating from pgSQL and WinXP to DB2 8.2 on SuSE 9.2 and I'd like to send E-Mails by triggers. I found some code for Java stored Procedures but I'm not able to get JavaDK running in...
17
by: rdemyan | last post by:
My app creates a building report. My users have requested that I provide functionality to e-mail these "building reports" to building managers once a month. So assuming that I have the...
10
by: muskan | last post by:
Hello, I have written this code for sending mails but is not working. Tell what should I have to write after the equal sign in SmtpMail.SmtpServer = ; so mail to be stored in...
7
by: oopsbabies | last post by:
Hello everyone, I am using Apache 1.3.33 as the web server and PHP version 4.3.10. My machine is using Windows XP 2002 professional edition which comes with a Windows firewall. I am using McAfee...
5
by: Sin Jeong-hun | last post by:
Hi. I would like to let users send bug reports or other messages to me. Maybe the easiest way to send e-mails from my application is just use the default e-mail agent by executing a link...
1
by: gowrik | last post by:
Hi can anyone know the coding for undelivered mails to the sender using jsp and servlets
6
by: Harshpandya | last post by:
Hi all, I am working on the form in which you fill out the whole PHP form and e mail that details to someone. It is working fine. But now i want to send the same form to be sent to different...
4
by: rohitchawla | last post by:
i dont know in which forum to post it in as it has both servlets and javascript in it i have made an ajax request to server side to read the values of a cookie and then send these values to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.