Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
12Activity
0 of .
Results for:
No results containing your search query
P. 1
All About Java Mail

All About Java Mail

Ratings:

4.88

(26)
|Views: 9,253 |Likes:
Published by Navneet
The document describes the usage of the Java Mail API to achieve the e-mail functionality with or without attachements.
The document describes the usage of the Java Mail API to achieve the e-mail functionality with or without attachements.

More info:

Published by: Navneet on Jan 26, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less

05/16/2013

 
JavaMail FAQ From jGuru
Generated Sep 13, 2005 2:11:33 PM 
How do I send email from a servlet?
Created 
: Sep 3, 1999
Modified 
: 2000-07-25 12:18:54.284Author:Alex Chaffee(http://www.jguru.com/guru/viewbio.jsp?EID=3)From: James Cooper (pixel@bitmechanic.com)GSP and GnuJSP both come with SMTP classes that make sending email very simple.if you are writing your own servlet you could grab one of the many SMTPimplementations from www.gamelan.com (search for SMTP and java). All the onesI've seen are pretty much the same -- open a socket on port 25 and drop the mailoff. so you have to have a mail server running that will accept mail from the machineJServ is running on.See also theJavaMail FAQfor a good list of Java mail resources, including SMTP andPOP classes.
Comments and alternative answers
 
 
If you want to use the JavaMail API, get it and create...
 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7), Jul 24,2000If you want to use the JavaMail API,get itand create a program similar to theHello World program.
See also
 Author: Alex Chaffee (http://www.jguru.com/guru/viewbio.jsp?EID=3), Sep 20, 2001This thread:Re: Automatically send and get mails using servlet...
Some examples
 Author: Chris Lack (http://www.jguru.com/guru/viewbio.jsp?EID=326717), Sep 21,2001I've written an "EMailClient" class for sending e-mails for my guestbook entries. I'vealso done an "InBox" servlet class that lists e-mails in your pop mail in-box so thatyou can delete or bounce them before downloading to your PC. Have a look at thecode, it might help -http://www.chris.lack.org and choose the java option on the professional menu.By the way you'll need JavaMail and Java Activation foundation from Sun if you'venot already downloaded them. You don't need your own mail server.
 
How can I send email from a JSP page?
Created 
: Nov 19, 1999
Modified 
: 2002-03-26 06:47:10.343Author:Govind Seshadri(http://www.jguru.com/guru/viewbio.jsp?EID=14)The JavaMAIL API is the standard mechanism for sending email. See the JavaMailFAQ for how to use it. You can place j2ee.jar (or mail.jar and activation.jar) underweb-inf/lib folder in tomcat3.2.4.You can send email from any JSP engine (like the JSWDK reference implementation)that supports the Sun specific sun.net.smtp package.(Statutory warning: Using internal Sun-specific packages is not an approach jGururecommends, as it will prevent your JSP pages from being truly portable.)The following scriptlet makes use of the SmtpClient class to send an email fromwithin a JSP page.
<%@ page import="sun.net.smtp.SmtpClient, java.io.*" %><%String from="gseshad@hotmail.com";String to="gov@jguru.com, govi@bigfoot.com";try{SmtpClient client = new SmtpClient("mail.xxxxx.xxx");client.from(from);client.to(to);PrintStream message = client.startMessage();message.println("To: " + to);message.println("Subject: Sending email from JSP!");message.println("This was sent from a JSP page!");message.println();message.println("Cool beans! :-)");message.println();message.println();client.closeServer();}catch (IOException e){System.out.println("ERROR SENDING EMAIL:"+e);}%>
Comments and alternative answers
 
 
error in the scriptlet
 Author: Fabio Mercuri (http://www.jguru.com/guru/viewbio.jsp?EID=1049210), Jan22, 2003after the line PrintStream message = client.startMessage(); the scriptlet sets in themessage stream the following attribute: message.println("To: " + to); in this way thereceived email will not display the from address! The correct lines are: PrintStreammessage = client.startMessage(); message.println("From: " + from);message.println("To: " + to); As regards
 
Re: error in the scriptlet
 Author: john turner (http://www.jguru.com/guru/viewbio.jsp?EID=1122937), Oct21, 2003I can never get the subject line to be included in the email when using theSmtpClient class. Don't think there's anything wrong with me code, it works perfectly well apart from this. Has anyone else had this problem?
String from="me@myDomain.com";String to = (String)session.getAttribute("enqEmail");String subject="Rate Response";try{SmtpClient client = new SmtpClient("Server");client.from(from);client.to(to);PrintStream message = client.startMessage();message.println("From: " + from);message.println("To: " + to);message.println("Subject: " + subject);
Re[2]: error in the scriptlet
 Author: Tushar Kapila (http://www.jguru.com/guru/viewbio.jsp?EID=1059392),Jan 22, 2004the subject should come before the To, thus: message.println("From: " + from);message.println("Subject: " + subject); message.println("To: " + to);
Take a look at the jakarta taglibs
 Author: Thiadmer Sikkema (http://www.jguru.com/guru/viewbio.jsp?EID=1079811),Jan 21, 2004Include the taglib declaration in your web.xml and use the following code in your JSP:
<%@ taglib uri="http://jakarta.apache.org/taglibs/mailer-1.1"prefix="mt" %><mt:mail server="home.net" to="foo@home.net"from="bar@home.net" subject="mail taglib"><mt:message>[body of message]</mt:message><mt:send/></mt:mail>
What do I need to acquire in order to get started with JavaMail?
Created 
: Jan 5, 2000
Modified 
: 2000-09-10 09:04:15.57Author:John Zukowski(http://www.jguru.com/guru/viewbio.jsp?EID=7)The reference JavaMail implementation is available from Sun fromhttp://java.sun.com/products/javamail/. You also need the JavaBeans ActivationFramework extension fromhttp://java.sun.com/beans/glasgow/jaf.html. If youintend to use JavaMail to read mail, you also need a POP3 provider and might wish topick up the provider that Sun offers (also available fromhttp://java.sun.com/products/javamail/).

Activity (12)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
gecseggy liked this
gecseggy liked this
Ivan Meneses liked this
Anatoly Osiko liked this
Hanan Ibrahim liked this
Juan Pastillo liked this
ysivaram liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->