×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: marcus bui
Added: Dec 23, 2014 7:30 AM
Views: 24
Tags: java mail
  1. def getSession(setup: ServerSetup): Session = {
  2.     val props: Properties = System.getProperties;
  3.     props.put("mail.smtps.starttls.enable", "true");
  4.     if (setup.isSecure()) {
  5.       props.setProperty("mail.smtp.socketFactory.class", classOf[DummySSLSocketFactory].getName);
  6.     }
  7.  
  8.     props.setProperty("mail.transport.protocol", setup.getProtocol());
  9.     props.setProperty("mail.smtp.host", String.valueOf(setup.getBindAddress()));
  10.     props.setProperty("mail.smtp.port", String.valueOf(setup.getPort()));
  11.     props.setProperty("mail.smtps.port", String.valueOf(setup.getPort()));
  12.     return Session.getInstance(props, null);
  13.   }