How do i authentication so that i can send a email through jsp a page

Thread Solved

Join Date: Sep 2008
Posts: 21
Reputation: dreamer14 is an unknown quantity at this point 
Solved Threads: 1
dreamer14 dreamer14 is offline Offline
Newbie Poster

How do i authentication so that i can send a email through jsp a page

 
0
  #1
Sep 17th, 2008
  1. <%@ page import="java.lang.,java.util.,javax.mail.,javax.mail.internet.,
  2. javax.activation.*" %>
  3. <%
  4. String p_to = "abc@hotmail.com"; // Please fill in your email here
  5. String p_from = "abcd@yahoo.com.sg"; // Please fill in receipient’s email here
  6. String p_subject = "Testing";
  7. String p_message = "This is a test email";
  8. String l_host = "smtp.mail.yahoo.com.sg";
  9. // Gets the System properties
  10. Properties l_props = new Properties();
  11. // Puts the SMTP server name to properties object
  12. l_props.put("mail.smtp.host", l_host);
  13. l_props.put("mail.smtp.port","25");
  14. l_props.put("mail.transport.protocol","smtp");
  15. l_props.put("mail.smtp.auth", "true");
  16. l_props.put("mail.user", "ancde");
  17. l_props.put("mail.password","password");
  18. // Get the default Session using Properties Object
  19. Session l_session = Session.getInstance(l_props, null);
  20. l_session.setDebug(false); // Enable the debug mode
  21. try {
  22. MimeMessage l_msg = new MimeMessage(l_session); // Create a New message
  23. l_msg.setFrom(new InternetAddress(p_from)); // Set the From address
  24. l_msg.setRecipients( Message.RecipientType.TO
  25. , InternetAddress.parse(p_to, false));
  26. l_msg.setSubject(p_subject); // Sets the Subject
  27. // Create and fill the first message part
  28. MimeBodyPart l_mbp = new MimeBodyPart();
  29. l_mbp.setText(p_message);
  30. // Create the Multipart and its parts to it
  31. Multipart l_mp = new MimeMultipart();
  32. l_mp.addBodyPart(l_mbp);
  33. // Add the Multipart to the message
  34. l_msg.setContent(l_mp);
  35. // Set the Date: header
  36. l_msg.setSentDate(new Date());
  37. // Send the message
  38. Transport.send(l_msg);
  39. // If program reaches this point, then message is successfully sent.
  40. out.print("Success");
  41. } catch (MessagingException mex) { // Trap the MessagingException Error
  42. out.print("Failure: Messaging Exception: " + mex);
  43. } catch (Exception e) {
  44. out.print("Failure: General Exception: " + e);
  45. e.printStackTrace();
  46. }
  47. %>
  48.  

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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,272
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 494
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: How do i authentication so that i can send a email through jsp a page

 
-1
  #2
Sep 17th, 2008
  1. 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
  2. You need to do some reading may be this can help
  3. 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
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 21
Reputation: dreamer14 is an unknown quantity at this point 
Solved Threads: 1
dreamer14 dreamer14 is offline Offline
Newbie Poster

Re: How do i authentication so that i can send a email through jsp a page

 
0
  #3
Sep 17th, 2008
Oh i see thanks for the help.
Do you have any idea how yahoo will allow that?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,272
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 494
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: How do i authentication so that i can send a email through jsp a page

 
-1
  #4
Sep 17th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1129 | Replies: 3
Thread Tools Search this Thread



Tag cloud for JSP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC