473,586 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6940

"mihir" <mi*****@indiat imes.com> wrote in message
news:3a******** *************** ***@posting.goo gle.com...
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.getDefa ultInstance(new
java.util.Prope rties(), null);
Transport transport = session2.getTra nsport("smtp");
transport.conne ct /* to a mailserver that can send the mail */
(
mailserver
, "username"
, "password"
);

MimeMessage email = new MimeMessage(ses sion2);
email.setSubjec t("test");
email.setFrom(n ew InternetAddress ("yo**@address. com", "This is me"));
email.setRecipi ent
(
Message.Recipie ntType.TO
, new InternetAddress ("tohim/he*@redwood.com ", "Your friend")
);

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

email.setConten t(message, "text/plain");

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

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*****@indiat imes.com> wrote in message
news:3a******** *************** ***@posting.goo gle.com...
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.getDefa ultInstance(new
java.util.Prope rties(), null);
Transport transport = session2.getTra nsport("smtp");
transport.conne ct /* to a mailserver that can send the mail */
(
mailserver
, "username"
, "password"
);

MimeMessage email = new MimeMessage(ses sion2);
email.setSubjec t("test");
email.setFrom(n ew InternetAddress ("yo**@address. com", "This is me"));
email.setRecipi ent
(
Message.Recipie ntType.TO
, new InternetAddress ("tohim/he*@redwood.com ", "Your friend")
);

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

email.setConten t(message, "text/plain");

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

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
1679
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 webserver. I try to write a website which allow to send order form to email. Now I facing the problem, because I need to test it at localhost. Can...
2
1831
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 my DB2 instance. So is there any other way to send mails by triggers out of my DB2? Procedure Code in C or some Software like dbmail from...
17
7626
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 following table that lists a building manager's name, e-mail address and their building, is there a way that I can automate this to send these monthly...
10
3830
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 /Inetpub/mailroot/queue & also how can I send External mails throu this code. MailMessage msgmail= new MailMessage();
7
7725
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 free edition for anti-virus. I use an ISP provider from my country and according to them I do not need to perform authentication while sending...
5
4212
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 mailto://mymail@domail.com. But this only works if the user has configured Outlook or something. Many users use web-based mails here so if I do so,...
1
1310
by: gowrik | last post by:
Hi can anyone know the coding for undelivered mails to the sender using jsp and servlets
6
6887
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 people and user should be able choose the check boxes to whom they want to send e mail to. I write some code simple If else conditions but i think i am...
4
5702
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 javascript file and then close the connection ive done the part of sending and receiving but i dont know how to close the connection after that what...
0
7841
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8339
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.