| | |
sending email
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 2
Reputation:
Solved Threads: 0
hi,
i want to send e-mail using jsp. when i run my code no error is shown but the message is not
sent to email address.
here is the code
i want to send e-mail using jsp. when i run my code no error is shown but the message is not
sent to email address.
here is the code
html Syntax (Toggle Plain Text)
<html> <body> <form method=post action="aa.jsp" > sender<input type=text name=text1><br> Reciever<input type=text name=text2><br> Subject<input type=text name=text3><br> Message<textarea name='area1' rows=5 cols=30> </textarea> <input type=submit> </form> </body> </html> <%@page language="java" import="java.io.*,javax.activation.*,javax.servlet.*,javax.servlet.http.*, javax.mail.*,javax.mail.internet.*,javax.mail.event.*, java.net.*,java.util.*,com.mysql.jdbc.Driver" session="true" %> <% response.setContentType("text/html"); try { out.println("acb"); Properties props=new Properties(); props.put("mail.smtp.host", "smtp.jcom.net"); Session session1 = Session.getDefaultInstance(props,null); String s1 = request.getParameter("text1"); String s2 = request.getParameter("text2"); out.println("acb"); String s3 = request.getParameter("text3"); String s4 = request.getParameter("area1"); Message message =new MimeMessage(session1); message.setFrom(new InternetAddress(s1)); message.setRecipients (Message.RecipientType.TO,InternetAddress.parse(s2,false)); message.setSubject(s3); message.setText(s4); out.println("acb"); Transport.send(message); out.println("acb"); out.println("mail has been sent"); } catch(Exception ex) { System.out.println("ERROR....."+ex); } %>
Last edited by peter_budo; Mar 17th, 2008 at 10:50 pm. Reason: Code tags are [code] not <code> :-)
Not only are you abusing JSP for something it's not meant to be used for, but you're also eating exceptions (catching them without doing anything with them).
No wonder you don't get to see errors if you don't log them.
1) always log or otherwise handle any exception you catch
2) never use Java code in JSP
3) never use JSP for anything except displaying results to the client, use servlets instead.
No wonder you don't get to see errors if you don't log them.
1) always log or otherwise handle any exception you catch
2) never use Java code in JSP
3) never use JSP for anything except displaying results to the client, use servlets instead.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- Sending email from a shell script (Shell Scripting)
- Sending HTML/Plain text Emails (PHP)
- Option of sending email either by Outlook or CDO (VB.NET)
- c++ (sending email) (C++)
- Sending HTML email via PHP mail function (PHP)
- Sending email from c++ application (C++)
- Need help on sending email with image and text (Growing an Online Community)
- CDONTS email goes directly to Badmail folder (ASP)
- email mail deliver error?? virus? (Windows NT / 2000 / XP)
Other Threads in the JSP Forum
- Previous Thread: View Image in jsp
- Next Thread: JSP: Cascading option box problems ...
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






