| | |
How do i authentication so that i can send a email through jsp a page
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 21
Reputation:
Solved Threads: 1
jsp Syntax (Toggle Plain Text)
<%@ page import="java.lang.,java.util.,javax.mail.,javax.mail.internet., javax.activation.*" %> <% String p_to = "abc@hotmail.com"; // Please fill in your email here String p_from = "abcd@yahoo.com.sg"; // Please fill in receipient’s email here String p_subject = "Testing"; String p_message = "This is a test email"; String l_host = "smtp.mail.yahoo.com.sg"; // Gets the System properties Properties l_props = new Properties(); // Puts the SMTP server name to properties object l_props.put("mail.smtp.host", l_host); l_props.put("mail.smtp.port","25"); l_props.put("mail.transport.protocol","smtp"); l_props.put("mail.smtp.auth", "true"); l_props.put("mail.user", "ancde"); l_props.put("mail.password","password"); // Get the default Session using Properties Object Session l_session = Session.getInstance(l_props, null); l_session.setDebug(false); // Enable the debug mode try { MimeMessage l_msg = new MimeMessage(l_session); // Create a New message l_msg.setFrom(new InternetAddress(p_from)); // Set the From address l_msg.setRecipients( Message.RecipientType.TO , InternetAddress.parse(p_to, false)); l_msg.setSubject(p_subject); // Sets the Subject // Create and fill the first message part MimeBodyPart l_mbp = new MimeBodyPart(); l_mbp.setText(p_message); // Create the Multipart and its parts to it Multipart l_mp = new MimeMultipart(); l_mp.addBodyPart(l_mbp); // Add the Multipart to the message l_msg.setContent(l_mp); // Set the Date: header l_msg.setSentDate(new Date()); // Send the message Transport.send(l_msg); // If program reaches this point, then message is successfully sent. out.print("Success"); } catch (MessagingException mex) { // Trap the MessagingException Error out.print("Failure: Messaging Exception: " + mex); } catch (Exception e) { out.print("Failure: General Exception: " + e); e.printStackTrace(); } %>
i get this error message
Failure: Messaging Exception: javax.mail.AuthenticationFailedException
How do i solve this?
All help will be greatly appreciated thanks
Last edited by cscgal; Sep 17th, 2008 at 2:44 am. Reason: Added code tags
- You do not want to do this sort of thing in JSP which is for view, you need to do it in an object or method called by servlet
- You need to do some reading may be this can help
- You need to find out how Yahoo enable 3rd parties to use their email services
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Nope, but if you search forum there been already few attempts so maybe some of them got it right, otherwise you need check Yahoo resources
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Other Threads in the JSP Forum
- Previous Thread: please help with passing array list to jsp
- Next Thread: how to handle multiple forms in jsp
Views: 1129 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






