Send Email In Jsp
In this tutorial I will explain how to send email in jsp and solutions of problems occurred when send email from application. In this tutorial I will also explain the complete procedure to implement sending email without any error. If we use email sending facilities in project or application then project become more efficient and attractive. But to implement sending email in project is more difficult task and get many errors. So this encourage me to publish this tutorial.
Question Answer of send email in jsp
Question:-Use of send email in project or web application?
Ans:- Before start see procedure of sending email in jsp application we need to know about use of sending email in project. We can use sending email in project or application or web application for feed back support and for contact support system in project. Best use of sending email is if your application is support login system then the password is send to email of user when the signup or change or password. Above were only few points which came to my mind but we can use send email many more area.
Question:-What is need to send email? (Requirements)
Ans:- To send email we need following things, which is as
1. JSP Editor:- First we need editor for editing files, which may be *.jsp, *.html, *.java etc. You can use any editor but if you use “Macromedia Dreamweave” software then you easily edit files because of this provide the view of edited page.
2. Application server or Servlet container:- To run *.jsp, *.java files server is required. You can use Tomcat server but if you use Sun Java™ System Application Server Platform.In this better platform provide to run *.jsp files.
3. javaMail jar file:- If your JDK with J2EE not contain javaMail( mail.jar) then you need to download it. You can download it here Sun’s JavaMail. If you download it then you need to put it into lib folder of server. If you want to use it only for your application then you can put it into WEB-INF/lib.
4. SMTP host address:- SMTP host address is required to send email over internet from your application. SMTP stands for simple mail transport protocol. It allows us to send emails. If you have domain email and your hosting provide smtp services emails then you can use it.
If you not any hosting emails then you can use free email host addresses just like
gmail, yahoo etc.
smtp host address of my site is- smtp.computerscienceartilce.in
For gmail- smtp.gmail.com
yahoo- smtp.yahoo.com
You can use localhost as smtp host.
How to send email?
Ok now lets see how to send email.
To send email you need minimum two files first is data entry file and second is send process.
Data entry files may be simple html file or jsp file. In this file we use form to enter required data.
lets see the DataEntry.jsp file preview.

data entry page preview of send email in jsp
Download this DataEntry.jsp file.
Second file is send process file, it must be *.jsp file because of in this jsp scripts is used.
Download sendProcess.jsp file.
In this file some term must be change according to your host and other.
First is host this must be your hosting address of smtp.
port port is may be 25, 587, 465. this is depend upon the use of connection.
means that the for localhost you can use port 25.
for TLS connection use port 587 and for SSL connection port is 465.
Next term change is username and password. User name of your mail hosting and password.
Question:- Common error occurred during send email.
And:- During send email many errors occurred. some of is explain here and also solution of that problems.
1. javax.mail.AuthenticationFailedException: failed to connect
Ans:- This type of error is occurred due to wrong username and password to authenticate to host server.
2. java.io.FilePermission (read, write). setting error.
Ans:- This error is due to JDK not permit to read and write anything by application. This error is can solve grant permission using policytool.exe in jdk bin folder.
If you have any problem then comment here. I will help you.
This is such an amazing article… Thank you so much for explaining things in such a precise manner. RESPECT!
An error occurred at line: 34 in the jsp file: /EmailsendProcess.jsp
Session cannot be resolved to a type
An error occurred at line: 46 in the jsp file: /EmailsendProcess.jsp
Message cannot be resolved to a type
An error occurred at line: 47 in the jsp file: /EmailsendProcess.jsp
InternetAddress cannot be resolved to a type
An error occurred at line: 48 in the jsp file: /EmailsendProcess.jsp
InternetAddress cannot be resolved to a type
An error occurred at line: 57 in the jsp file: /EmailsendProcess.jsp
Transport cannot be resolved to a type.
plz rply how to resolve this problem…
An error occurred at line: 13 in the jsp file: /test/SendProcess.jsp
Generated servlet error:
Syntax error on token "to", delete this token
An error occurred at line: 13 in the jsp file: /test/SendProcess.jsp
Generated servlet error:
Syntax error on token "from", delete this token
An error occurred at line: 13 in the jsp file: /test/SendProcess.jsp
Generated servlet error:
Syntax error on token "host", invalid AssignmentOperator
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
It may be forgot to add assignment operator in line 13, where the 'to' 'from' 'host' string is initialized.
So check your code where the these variable is declared and initialized. And also check DataEntry.jsp file also where in form check text box name is 'to' and 'from'.
It may be due to alter some operator in CODE tag while posting in site.
If you still face problem then download both files from here
DataEntry.jsp
sendProcess.jsp
its working perfectly thanks a lot
hi code is fine working..thanks alot..,but it sending a mail twise why?
please reply asap
Some time due to server response this type of problem may occurs.
For solution restart your server and send mail.
restart tomcat you mean? but it is still ending it twice
hi, I'm using netbeans ide 6.9 and google chrome as web browser. though i'm logged in, it is generating an exception
javax.mail.AuthenticationFailedException: 535-5.7.1 Please log in with your web browser and then try again.
can u plz me?? thanks in advance 🙂
hi thanks for quick reply,i faced another problem i.e,if i given not created email address also sending mail…i want send a mail to
existing mail ids only …how to validate this type of address.
For validation of emails add the following code in DataEntry.jsp page replace this code
if(document.form1.to.value=="")
{
alert("Email can't blank…");
document.form1.to.focus();
document.form1.to.style.backgroundColor = "#FF9966";
document.form1.to.select();
return false;
}
with this CODE :
var x=document.forms["form1"]["to"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos 2 || dotpos 2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
This code check your email address is valid email or not
This type of error is occurred due to wrong username and password to authenticate to host server.
hi suppose i entered an email i.e, thiruveedi456@gmail.com,this is not available in gmail server but it sending a mail.how to validate this type of validations.
For this you need to use SMTP commands to check if mail address exist or not.
See the procedure step by step.
Step-1- At first connect to server of particular email using MX record.
To find MX record you can use java code MXLookup.java . or using CMD command is
"nslookup -type =MX gmail.com"
Step-2- Pefrom HELO
This command is as : HELO server.com
Step-3- Fire MAIL FROM command
this command is : MAIL FROM:
Step-4- Fire RCPT TO command and check Response
This command is : RCPT TO:
If the response is 550 this means that the specified email does not exits on server and email is invalid.
thanks for giving reply.please give full java code to perform the validation i.e,email exist or not. i'm getting confused where i've to execute that SMTP commands.
You can read how to use smtp commands and validate email
here
nice post. thanks.
Hii i’m using myecilipse to run this program but getting error msg given below
i used all jar file related to this mail mail.jar
so reply me if i’m going wrong somewhere or what is this error ??
org.apache.jasper.JasperException: An exception occurred processing JSP page /sendProcess.jsp at line 46
43: // Instantiate a new MimeMessage and fill it with the
44: // required information.
45:
46: Message msg = new MimeMessage(mailSession);
47: msg.setFrom(new InternetAddress(from));
48: InternetAddress[] address = {new InternetAddress(to)};
49: msg.setRecipients(Message.RecipientType.TO, address);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/activation/DataSource
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:132)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NoClassDefFoundError: javax/activation/DataSource
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
This type of error may be due to 2 reasons.
First one is mail.jar is not being included in the WAR deployed to Tomcat.
For this check the mail.jar include in Way deployed to tomcat or not.
You can add right clicked on project folder –>Properties–>Java Build Path –>Libraries Tab –> and add mail.jar
or
Second reason is due to
Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication("UserName", "Password");}});
not return valid mailSession value,
please check you enter proper UserName and Password.
Namaste sir!
iam geting this error what should i do.
error:
HTTP Status 404 – /EmailsendProcess.jsp
type Status report
message /EmailsendProcess.jsp
description The requested resource (/EmailsendProcess.jsp) is not available.
Apache Tomcat/5.5.20.
i did:sendmail/dataentry , send process ,WEB-INF/mail.jar.
so ,where i did mistake iam not found plz tell me sir
Please check “DataEntry.jsp” file in forum tag action file must be “sendProcess.jsp”. Due to in-proper linking of action file, this type of error occurs.
namaste sir,
I Tryed but i got this erros, what should i do sir plz teel me
Errors:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /SendProcess.jsp:58
55: // for delivery.
56:
57: Transport transport = mailSession.getTransport(“smtp”);
58: transport.connect(host, “UserName”, “Password”);
59: transport.sendMessage(msg, msg.getAllRecipients());
60: transport.send(msg);
61: out.println(“Mail was sent to “+to);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: 535-5.7.1 Please log in with your web browser and then try again. Learn more at
535 5.7.1 https://support.google.com/mail/bin/answer.py?answer=78754 op10sm7859593pbc.75
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.SendProcess_jsp._jspService(SendProcess_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.mail.AuthenticationFailedException: 535-5.7.1 Please log in with your web browser and then try again. Learn more at
535 5.7.1 https://support.google.com/mail/bin/answer.py?answer=78754 op10sm7859593pbc.75
com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:809)
com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:752)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:669)
javax.mail.Service.connect(Service.java:317)
javax.mail.Service.connect(Service.java:176)
org.apache.jsp.SendProcess_jsp._jspService(SendProcess_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
58: transport.connect(host, “UserName”, “Password”);
In this line put your user name at “UserName” and password at “Password” of mail host. User name and password must be required for send mail using mail host.
Hey,
What is this username and password stands for?
I dont have any host. I have gmail account. Does this username and password are my gmail account password?
Here UserName and Password is of your mail host user name and password. If you use gmail account then username and password of gmail account.
Hi sir,
Can you tell me how to send multiple emails at the same time.Sending emails to many users.
To send multiple emails at the same time use array of email id’s. and use the following method
void addRecipients(Message.RecipientType type,
Address[] addresses)
throws MessagingException
In this “type” is may be TO, CC (Carbon Copy), BCC (Black Carbon Copy). and “addresses” is array of email id’s.
im getting the following error
Session cannot be resolved to a type
32: props.put(“mail.smtp.socketFactory.fallback”, “false”);
33: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
34:
35: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(“XxxXX”, “XxXXX”);
36: }
37: });
38:
pls i am writing a simple standalone app using javamail.so i hve been trying to send message it keep on showing me an error “can not connect to the server smtp.gmail.com port:587” .so i asked how can my simple app send email to my specified address. Omile from Nigeria new to javamail
This problem may occur due to property used in javamail app. Use the following property’s
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
You can simply download both file from
DataEntry.jsp
sendEmailProcess.jsp
Hii i’m using myecilipse 10 to run this program but getting error msg given below
i used all jar file related to this mail mail.jar
so reply me if i’m going wrong somewhere or what is this error ??
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /sendProcess.jsp at line 60
57: Transport transport = mailSession.getTransport(“smtp”);
58: transport.connect(host, “username”, “password”);
59: transport.sendMessage(msg, msg.getAllRecipients());
60: transport.send(msg);
61: out.println(“Mail was sent to “+to);
62: out.println(” from “+from);
63: out.println(” using host “+host+”.”);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: javax.mail.AuthenticationFailedException: 535-5.7.1 Please log in with your web browser and then try again. Learn more at
535 5.7.1 https://support.google.com/mail/bin/answer.py?answer=78754 tq4sm39652468pbc.50
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:132)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.mail.AuthenticationFailedException: 535-5.7.1 Please log in with your web browser and then try again. Learn more at
535 5.7.1 https://support.google.com/mail/bin/answer.py?answer=78754 tq4sm39652468pbc.50
com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:823)
com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:756)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:673)
javax.mail.Service.connect(Service.java:317)
javax.mail.Service.connect(Service.java:176)
javax.mail.Service.connect(Service.java:125)
javax.mail.Transport.send0(Transport.java:194)
javax.mail.Transport.send(Transport.java:124)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Si i still havent understood what exactly we r suppose to replace “username” and Password with.
coz i am getting the below error when i try to run the code
org.apache.jasper.JasperException: Exception in JSP: /sendProcess.jsp:46
43: // Instantiate a new MimeMessage and fill it with the
44: // required information.
45:
46: Message msg = new MimeMessage(mailSession);
47: msg.setFrom(new InternetAddress(from));
48: InternetAddress[] address = {new InternetAddress(to)};
49: msg.setRecipients(Message.RecipientType.TO, address);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
javax.servlet.ServletException: javax/activation/DataSource
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.lang.NoClassDefFoundError: javax/activation/DataSource
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:92)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.36 logs.
please help
i m getting this error……with ur code
java.net.UnknownHostException: smtp.gmail.com
java.net.PlainSocketImpl.connect(Unknown Source)
java.net.SocksSocketImpl.connect(Unknown Source)
java.net.Socket.connect(Unknown Source)
please help urgent !!!!!!!!!!!!
thnaks in advance
Try different ports. Ports may be 25, 587, 465. these depends upon the use of connection.
means that the for localhost you can use port 25.
for TLS connection use port 587 and for SSL connection port is 465.
thanks for the reply……
i more thing …if my server is smtp server without ssl ot tls then what changes in the code are required???
please help its very imp.
thanks
Simply use port 25.
Hii Sir you have written good example and i successfully get the mail but then after i got the error like……
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /sendProcess.jsp at line 60
57: Transport transport = mailSession.getTransport(“smtp”);
58: transport.connect(host, “my user name”, “my password”);
59: transport.sendMessage(msg, msg.getAllRecipients());
60: transport.send(msg);
61: out.println(“Mail was sent to “+to);
62: out.println(” from “+from);
63: out.println(” using host “+host+”.”);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
javax.servlet.ServletException: javax.mail.MessagingException: Could not connect to SMTP host: gmail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection timed out: connect
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:132)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
javax.mail.MessagingException: Could not connect to SMTP host: gmail.com, port: 465;
nested exception is:
java.net.ConnectException: Connection timed out: connect
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
javax.mail.Service.connect(Service.java:317)
javax.mail.Service.connect(Service.java:176)
javax.mail.Service.connect(Service.java:125)
javax.mail.Transport.send0(Transport.java:194)
javax.mail.Transport.send(Transport.java:124)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
java.net.ConnectException: Connection timed out: connect
java.net.PlainSocketImpl.socketConnect(Native Method)
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
java.net.Socket.connect(Socket.java:525)
com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:550)
com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288)
com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:205)
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
javax.mail.Service.connect(Service.java:317)
javax.mail.Service.connect(Service.java:176)
javax.mail.Service.connect(Service.java:125)
javax.mail.Transport.send0(Transport.java:194)
javax.mail.Transport.send(Transport.java:124)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
Hi Abhimanyu,
Comment out one line either 59 or 60.
59: transport.sendMessage(msg, msg.getAllRecipients());
60: transport.send(msg);
hii..how to solve this error?
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;
nested exception is:
java.net.UnknownHostException: smtp.gmail.com
root cause
hi..
How to solve this error..?
javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;
nested exception is:
java.net.UnknownHostException: smtp.gmail.com
root cause
java.net.UnknownHostException: smtp.gmail.com
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
please give me full code to verify email id is whether exist or not on server,along with send email code that you had posted…
Wow, it such a nice tuto… thxs for post. its working fine
sir i am getting this error though i have replaced username and password correctly.
please tell how to resolve it, i badly need it
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 35 in the jsp file: /sendProcess.jsp
Session cannot be resolved to a type
32: props.put(“mail.smtp.socketFactory.fallback”, “false”);
33: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
34: System.out.println(“what to do”);
35: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator()
36: {
37: protected PasswordAuthentication getPasswordAuthentication() {
38: return new PasswordAuthentication(“brainlessnewton@gmail.com”, “alberteinstein”);
An error occurred at line: 35 in the jsp file: /sendProcess.jsp
Session cannot be resolved
32: props.put(“mail.smtp.socketFactory.fallback”, “false”);
33: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
34: System.out.println(“what to do”);
35: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator()
36: {
37: protected PasswordAuthentication getPasswordAuthentication() {
38: return new PasswordAuthentication(“brainlessnewton@gmail.com”, “alberteinstein”);
An error occurred at line: 35 in the jsp file: /sendProcess.jsp
javax.mail.Authenticator cannot be resolved to a type
32: props.put(“mail.smtp.socketFactory.fallback”, “false”);
33: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
34: System.out.println(“what to do”);
35: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator()
36: {
37: protected PasswordAuthentication getPasswordAuthentication() {
38: return new PasswordAuthentication(“brainlessnewton@gmail.com”, “alberteinstein”);
An error occurred at line: 50 in the jsp file: /sendProcess.jsp
Message cannot be resolved to a type
47: // Instantiate a new MimeMessage and fill it with the
48: // required information.
49:
50: Message msg = new MimeMessage(mailSession);
51: msg.setFrom(new InternetAddress(from));
52: InternetAddress[] address = {new InternetAddress(to)};
53: msg.setRecipients(Message.RecipientType.TO, address);
An error occurred at line: 50 in the jsp file: /sendProcess.jsp
MimeMessage cannot be resolved to a type
47: // Instantiate a new MimeMessage and fill it with the
48: // required information.
49:
50: Message msg = new MimeMessage(mailSession);
51: msg.setFrom(new InternetAddress(from));
52: InternetAddress[] address = {new InternetAddress(to)};
53: msg.setRecipients(Message.RecipientType.TO, address);
An error occurred at line: 51 in the jsp file: /sendProcess.jsp
InternetAddress cannot be resolved to a type
48: // required information.
49:
50: Message msg = new MimeMessage(mailSession);
51: msg.setFrom(new InternetAddress(from));
52: InternetAddress[] address = {new InternetAddress(to)};
53: msg.setRecipients(Message.RecipientType.TO, address);
54: msg.setSubject(subject);
An error occurred at line: 52 in the jsp file: /sendProcess.jsp
InternetAddress cannot be resolved to a type
49:
50: Message msg = new MimeMessage(mailSession);
51: msg.setFrom(new InternetAddress(from));
52: InternetAddress[] address = {new InternetAddress(to)};
53: msg.setRecipients(Message.RecipientType.TO, address);
54: msg.setSubject(subject);
55: msg.setSentDate(new Date());
An error occurred at line: 53 in the jsp file: /sendProcess.jsp
Message.RecipientType.TO cannot be resolved to a type
50: Message msg = new MimeMessage(mailSession);
51: msg.setFrom(new InternetAddress(from));
52: InternetAddress[] address = {new InternetAddress(to)};
53: msg.setRecipients(Message.RecipientType.TO, address);
54: msg.setSubject(subject);
55: msg.setSentDate(new Date());
56: msg.setText(messageText);
An error occurred at line: 61 in the jsp file: /sendProcess.jsp
Transport cannot be resolved to a type
58: // Hand the message to the default transport service
59: // for delivery.
60:
61: Transport transport = mailSession.getTransport(“smtp”);
62: transport.connect(host, “brainlessnewton@gmail.com”, “alberteinstein”);
63: transport.sendMessage(msg, msg.getAllRecipients());
64: transport.send(msg);
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Great Bharat It helped me a lot
How one can send the attachment to multiple Recipients
can you send me a complete code
Its reakky GREAT
THANKS !
An error occurred at line: 34 in the jsp file: /sendProcess.jsp
Session cannot be resolved to a type
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(“UserName”, “Password”);
35: }
36: });
37:
An error occurred at line: 34 in the jsp file: /sendProcess.jsp
Session cannot be resolved
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(“UserName”, “Password”);
35: }
36: });
37:
An error occurred at line: 34 in the jsp file: /sendProcess.jsp
javax.mail.Authenticator cannot be resolved to a type
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(“UserName”, “Password”);
35: }
36: });
37:
An error occurred at line: 46 in the jsp file: /sendProcess.jsp
Message cannot be resolved to a type
43: // Instantiate a new MimeMessage and fill it with the
44: // required information.
45:
46: Message msg = new MimeMessage(mailSession);
47: msg.setFrom(new InternetAddress(from));
48: InternetAddress[] address = {new InternetAddress(to)};
49: msg.setRecipients(Message.RecipientType.TO, address);
An error occurred at line: 46 in the jsp file: /sendProcess.jsp
MimeMessage cannot be resolved to a type
43: // Instantiate a new MimeMessage and fill it with the
44: // required information.
45:
46: Message msg = new MimeMessage(mailSession);
47: msg.setFrom(new InternetAddress(from));
48: InternetAddress[] address = {new InternetAddress(to)};
49: msg.setRecipients(Message.RecipientType.TO, address);
An error occurred at line: 47 in the jsp file: /sendProcess.jsp
InternetAddress cannot be resolved to a type
44: // required information.
45:
46: Message msg = new MimeMessage(mailSession);
47: msg.setFrom(new InternetAddress(from));
48: InternetAddress[] address = {new InternetAddress(to)};
49: msg.setRecipients(Message.RecipientType.TO, address);
50: msg.setSubject(subject);
An error occurred at line: 48 in the jsp file: /sendProcess.jsp
InternetAddress cannot be resolved to a type
45:
46: Message msg = new MimeMessage(mailSession);
47: msg.setFrom(new InternetAddress(from));
48: InternetAddress[] address = {new InternetAddress(to)};
49: msg.setRecipients(Message.RecipientType.TO, address);
50: msg.setSubject(subject);
51: msg.setSentDate(new Date());
An error occurred at line: 49 in the jsp file: /sendProcess.jsp
Message.RecipientType.TO cannot be resolved to a type
46: Message msg = new MimeMessage(mailSession);
47: msg.setFrom(new InternetAddress(from));
48: InternetAddress[] address = {new InternetAddress(to)};
49: msg.setRecipients(Message.RecipientType.TO, address);
50: msg.setSubject(subject);
51: msg.setSentDate(new Date());
52: msg.setText(messageText);
An error occurred at line: 57 in the jsp file: /sendProcess.jsp
Transport cannot be resolved to a type
54: // Hand the message to the default transport service
55: // for delivery.
56:
57: Transport transport = mailSession.getTransport(“smtp”);
58: transport.connect(host, “UserName”, “Password”);
59: transport.sendMessage(msg, msg.getAllRecipients());
60: transport.send(msg);
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Plz Solve this error
javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect
Use port number 465. Because of the Google use SSL connection.
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 34 in the jsp file: /placement/sendProcess.jsp
Session cannot be resolved to a type
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication()
35: }
36: });
37:
An error occurred at line: 34 in the jsp file: /placement/sendProcess.jsp
Session cannot be resolved
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication()
35: }
36: });
37:
An error occurred at line: 34 in the jsp file: /placement/sendProcess.jsp
javax.mail.Authenticator cannot be resolved to a type
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication();
35: }
36: });
37:
HTTP Status 500 – An exception occurred processing JSP page /sendProcess.jsp at line 58 55: // for delivery. 56: 57: Transport transport = mailSession.getTransport(“smtp”); 58: transport.connect(host, “yogi.hammerhead@gmail.com”, “mypassword”); 59: transport.sendMessage(msg, msg.getAllRecipients()); 60: transport.send(msg); 61: out.println(“Mail was sent to “+to); Stacktrace:
Why am I getting this error ?
hi dude its working fine.. but i need to send some more fields like phone number along with the text and subject how to get the parameters to sendProcess.jsp file and to the message sending phase
as like
message.setText
message.setSubject
how for a phone number
plz give solution its imp for my project
thanks in advance
You can simply add new field to message using
String phone = request.getParameter("phone");
messageText=messageText+"</br>Phone Number:"+phone;
HTTP Status 500 –
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.mail.AuthenticationFailedException: 535-5.7.1 Please log in with your web browser and then try again. Learn more at
535 5.7.1 https://support.google.com/mail/bin/answer.py?answer=78754 m18sm15443743pad.17 – gsmtp
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
javax.servlet.ServletException: javax.mail.AuthenticationFailedException: 535-5.7.1 Please log in with your web browser and then try again. Learn more at
535 5.7.1 https://support.google.com/mail/bin/answer.py?answer=78754 m18sm15443743pad.17 – gsmtp
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.EmailsendProcess_jsp._jspService(EmailsendProcess_jsp.java:142)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
javax.mail.AuthenticationFailedException: 535-5.7.1 Please log in with your web browser and then try again. Learn more at
535 5.7.1 https://support.google.com/mail/bin/answer.py?answer=78754 m18sm15443743pad.17 – gsmtp
com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
javax.mail.Service.connect(Service.java:317)
javax.mail.Service.connect(Service.java:176)
javax.mail.Service.connect(Service.java:125)
javax.mail.Transport.send0(Transport.java:194)
javax.mail.Transport.send(Transport.java:124)
org.apache.jsp.EmailsendProcess_jsp._jspService(EmailsendProcess_jsp.java:127)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.
Apache Tomcat/7.0.27
Now after including all libraries of java mail i am getting the following error
Please help
type Exception report
message Unable to compile class for JSP:
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 36 in the jsp file: /EmailsendProcess.jsp
Session cannot be resolved to a type
33:
34: Properties props = new Properties();
35: props.put(“somthign”, “localhost”);
36: Session mailSession = Session.getInstance(props);
37:
Sir i am getting this error when running the code….
Can you please help
org.apache.jasper.JasperException: Exception in JSP: /sendProcess.jsp:58
55: // for delivery.
56:
57: Transport transport = mailSession.getTransport(“smtp”);
58: transport.connect(host, “stsantoshtewari836@gmail.com”, “8972958057”);
59: //transport.sendMessage(msg, msg.getAllRecipients());
60: transport.send(msg);
61: out.println(“Mail was sent to “+to);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: Could not connect to SMTP host: smtp.gmail.com, port: 465
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.SocketException: Connection reset
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
javax.mail.Service.connect(Service.java:295)
javax.mail.Service.connect(Service.java:176)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.16 logs.
Its always comming i also used 25,587
sir I am getting following exception in the following line no:59
59: transport.sendMessage(msg, msg.getAllRecipients());
javax.servlet.ServletException: javax.mail.MessagingException: No MimeMessage content
Sir while running the program I am getting the following exception in line 59.
59: transport.sendMessage(msg, msg.getAllRecipients());
javax.servlet.ServletException: javax.mail.MessagingException: No MimeMessage content.
sir pls tell me what is port in the following two lines. they must be same or different ?
props.put(“mail.smtp.port”, “25”);
….
….
….
….
props.put(“mail.smtp.socketFactory.port”, “465”);
…
…
…
Both port value must be same.
If you use port 465 for secure layer then in both line use 465.
Sir,
It works Fine with me. I have a query that, can i attach attachment file in this same files and if YES kindly assist me as it is very important for me last year project.
Also Sir do you have any idea how to send SMS to mobile phone from my Web APP(my project website).
Please try to reply ASAP
sir if i am giving port no as 465 then i am getting this exception
javax.servlet.ServletException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
if i am giving port no as 25 then i am getting this exception
javax.servlet.ServletException: javax.mail.MessagingException: No MimeMessage content
please help me out.
Sir,
It works Fine with me. I have a query that, can i attach attachment file in this same files and if YES kindly assist me as it is very important for me last year project.
Also Sir do you have any idea how to send SMS to mobile phone from my Web APP(my project website).
Please try to reply ASAP
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /sendProcess.jsp at line 48
45:
46: Message msg = new MimeMessage(mailSession);
47: msg.setFrom(new InternetAddress(“lakshmid.111@gmail.com”));
48: InternetAddress[] address = {new InternetAddress(to)};
49: msg.setRecipients(Message.RecipientType.TO, address);
50: msg.setSubject(subject);
51: msg.setSentDate(new Date());
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
java.lang.NullPointerException
javax.mail.internet.InternetAddress.parse(InternetAddress.java:534)
javax.mail.internet.InternetAddress.(InternetAddress.java:61)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:114)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.
im getting dis type of exception and wen im submitng data entry page its not connecting with sending process page it raising abve exceptin in brwser
Sir i have asked a question on 26th march……….
can u please answer the question…….
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 34 in the jsp file: /placement/sendProcess.jsp
Session cannot be resolved to a type
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication()
35: }
36: });
37:
An error occurred at line: 34 in the jsp file: /placement/sendProcess.jsp
Session cannot be resolved
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication()
35: }
36: });
37:
An error occurred at line: 34 in the jsp file: /placement/sendProcess.jsp
javax.mail.Authenticator cannot be resolved to a type
31: props.put(“mail.smtp.socketFactory.fallback”, “false”);
32: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
33:
34: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication();
35: }
36: });
37:
An error occurred at line: 91 in the jsp file: /saveissuebook.jsp
The type PasswordAuthentication is ambiguous
88: props.put(“mail.smtp.socketFactory.fallback”, “false”);
89: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
90:
91: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(“tulasi9866422084”, “tulasi527”);
92: }
93: });
94:
An error occurred at line: 91 in the jsp file: /saveissuebook.jsp
The type PasswordAuthentication is ambiguous
88: props.put(“mail.smtp.socketFactory.fallback”, “false”);
89: props.put(“mail.smtp.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
90:
91: Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {protected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(“username”, “password”);
92: }
93: });
94:
IT SHOWING ERROR ABOUT
transport.send(msg);
javax.servlet.ServletException: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
I am getting this error , I send mail using localhost. but say wrong username and password of smtp. can u help me…….
It seems you enter wrong user name and password of your mail account. Enter correct user name and password.
noo!!! bharat bhai i hv entered it correctly… then it is showing this error..
showing me—-
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.mail.MessagingException:
How to send multiple emails ?
sir i am getting an error..
i am running it on my localhost tomcat server… what changes i have to make in my port..please tell
org.apache.jasper.JasperException: Exception in JSP: /sendProcess.jsp:58
55: // for delivery.
56:
57: Transport transport = mailSession.getTransport(“smtp”);
58: transport.connect(host, “*******@gmail.com”, “*********”);
59: transport.sendMessage(msg, msg.getAllRecipients());
60: transport.send(msg);
61: out.println(“Mail was sent to “+to);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: Unknown SMTP host: smtp.gmail.com
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;
nested exception is:
java.net.UnknownHostException: smtp.gmail.com
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1959)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
javax.mail.Service.connect(Service.java:295)
javax.mail.Service.connect(Service.java:176)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Hi, thanks a lot it worked n it helped me a lot…
i have one question is it possible to synchronize this email app with the calendar. Means which can send the events n schedules..
//please do help me with thir error.. m using this code for my college //project
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
Session cannot be resolved or is not a type
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
Session cannot be resolved
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
javax.mail.Authenticator cannot be resolved or is not a type
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
Message cannot be resolved or is not a type
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
MimeMessage cannot be resolved or is not a type
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
InternetAddress cannot be resolved or is not a type
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
InternetAddress[] cannot be resolved or is not a type
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
Message.RecipientType.TO cannot be resolved or is not a type
An error occurred at line: 13 in the jsp file: /sendProcess.jsp
Generated servlet error:
Transport cannot be resolved or is not a type
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:386)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:280)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:259)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:247)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
and the code is
Email send Example for project
//code
Email send Example for project
Thanks man , helped like crazy!
Please solve this error…
“Too many login attempts, please try again later. te2sm102708509pac.25 – gsmtp ”
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /sendProcess.jsp at line 60
57: Transport transport = mailSession.getTransport(“smtp”);
58: transport.connect(host, “username”, “password”);
59: //transport.sendMessage(msg, msg.getAllRecipients());
60: transport.send(msg);
61: out.println(“Mail was sent to “+to);
62: out.println(” from “+from);
63: out.println(” using host “+host+”.”);
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: javax.mail.AuthenticationFailedException: 454 4.7.0 Too many login attempts, please try again later. te2sm102708509pac.25 – gsmtp
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:132)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.mail.AuthenticationFailedException: 454 4.7.0 Too many login attempts, please try again later. te2sm102708509pac.25 – gsmtp
com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
javax.mail.Service.connect(Service.java:317)
javax.mail.Service.connect(Service.java:176)
javax.mail.Service.connect(Service.java:125)
javax.mail.Transport.send0(Transport.java:194)
javax.mail.Transport.send(Transport.java:124)
org.apache.jsp.sendProcess_jsp._jspService(sendProcess_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
Thanks boss…. Working well…!!
javax.mail.MessagingException: Exception reading response; nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1090)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:986)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:197)
at javax.mail.Service.connect(Service.java:233)
at javax.mail.Service.connect(Service.java:134)
at com.ibm._jsp._sendProcess._jspService(_sendProcess.java:145)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:101)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1240)
at [internal classes]
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:215)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1033)
at [internal classes]
these are the errors i am getting. Please help.
Thanks In advance
Sir, I am getting this error.. please help
javax.servlet.ServletException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
nested exception is:
java.net.SocketException: Connection reset
hey bharat this article is really very help full I want to ask you that if I want to create my own application using jsp for sending and receiving mail without using any real domain like gmail how can we do that. what r the things which I required.
Hi Sneha,
If you want to send and receive email you can use your domains for SMTP host.
Like smtp host address of my site is- smtp.computerscienceartilce.in