473,246 Members | 1,957 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,246 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 6918

"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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.