From: Bob J. <jac...@us...> - 2009-11-08 17:46:19
|
Update of /cvsroot/jmri/jmri/util/javamail In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10482/java/src/jmri/util/javamail Modified Files: MailMessage.java Log Message: fix report by routing to google group Index: MailMessage.java =================================================================== RCS file: /cvsroot/jmri/jmri/util/javamail/MailMessage.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MailMessage.java 7 Jun 2009 19:20:26 -0000 1.4 --- MailMessage.java 8 Nov 2009 17:46:08 -0000 1.5 *************** *** 78,82 **** String subject; ! String from = "ja...@ph..."; //! null String cc = null; String bcc = null; --- 78,82 ---- String subject; ! String from = "jmr...@gm..."; //! null String cc = null; String bcc = null; *************** *** 86,91 **** String protocol = null; String host = null; ! String user = null; ! String password = null; String record = null; // name of folder in which to record mail --- 86,93 ---- String protocol = null; String host = null; ! ! String user = "jmr...@gm..."; ! String password = "Hgytht756%gfA@f9"; ! String record = null; // name of folder in which to record mail *************** *** 109,117 **** // XXX - could use Session.getTransport() and Transport.connect() // XXX - assume we're using SMTP if (mailhost != null) { props.put("mail.smtp.host", mailhost); } // Get a Session object ! session = Session.getInstance(props, null); if (log.isDebugEnabled()) session.setDebug(true); --- 111,125 ---- // XXX - could use Session.getTransport() and Transport.connect() // XXX - assume we're using SMTP + props.put("mail.transport.protocol", "smtp"); + props.put("mail.smtp.starttls.enable","true"); if (mailhost != null) { props.put("mail.smtp.host", mailhost); } + props.put("mail.smtp.auth", "true"); + + Authenticator auth = new SMTPAuthenticator(); + // Get a Session object ! session = Session.getInstance(props, auth); if (log.isDebugEnabled()) session.setDebug(true); *************** *** 219,222 **** --- 227,241 ---- } } + + /** + * SimpleAuthenticator is used to do simple authentication when the SMTP + * server requires it. + */ + private class SMTPAuthenticator extends javax.mail.Authenticator { + + public PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(user, password); + } + } static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(MailMessage.class.getName()); |