Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. Session session = null;
  2.  
  3. Context initalContext = new InitialContext();
  4. Context envContext = (Context) initalContext.lookup("java:comp/env");
  5.  
  6.  
  7. try{
  8. // Blows up here with a 500 error
  9. session = (Session) envContext.lookup("mail/Session");
  10. }
  11. catch (Exception e) {
  12. // No StackTrace printed
  13. e.printStackTrace();
  14. }
  15.  
  16. <Resource
  17. name="mail/Session"
  18. type="javax.mail.Session"
  19. auth="Container"
  20. mail.smtp.host="smtp.gmail.com"
  21. mail.smtp.socketFactory.port="465"
  22. mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
  23. mail.smtp.auth="true"
  24. mail.smtp.port="465"
  25. mail.from="XXXXXX@mailserver.com"
  26. mail.user="XXXXXX@mailserver.com"
  27. password="XXXXXX"
  28. />
  29.  
  30. <resource-ref>
  31. <description>Resource reference to a factory for javax.mail.Session instances that may be used for sending electronic mail messages, preconfigured to connect to the appropriate SMTP server.</description>
  32. <res-ref-name>mail/Session</res-ref-name>
  33. <res-type>javax.mail.Session</res-type>
  34. <res-auth>Container</res-auth>
  35. </resource-ref>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement