/** * Return bean implementation rather than interface. * @return */ @Bean public EmailService mailService() { SmtpConfig smtp = new SmtpConfig( CommonUIConfigManager.getConfigurationProperty( EIAppsPropertyKeys.EMAIL_HOST ), Integer.parseInt(CommonUIConfigManager.getConfigurationProperty( EIAppsPropertyKeys.EMAIL_PORT )), Boolean.parseBoolean(CommonUIConfigManager.getConfigurationProperty( EIAppsPropertyKeys.EMAIL_SSL )), CommonUIConfigManager.getConfigurationProperty( EIAppsPropertyKeys.EMAIL_USER ), CommonUIConfigManager.getConfigurationProperty( EIAppsPropertyKeys.EMAIL_PASSWORD ) ); return new EmailService(smtp); }
/** * @see org.eaglei.ui.gwt.search.stemcell.rpc.StemCellSearchServiceRemote#sendEmail(java.lang.String, java.lang.String, java.lang.String, String) */ @Override public void sendEmail( final String toName, final String toAddr, final String subject, final String message) { EmailMessage msg = null; try { msg = new EmailMessage(); msg.setSubject( subject ); msg.setPlainText( message ); // assume for now that toName is empty or null // toAddr is a comma-separated list,,,, //logger.trace( "sendEmail: toAddr = " + toAddr ); for (String addr : toAddr.split( "," )) { //logger.trace( "sendEmail: addr = " + addr ); msg.addRecipient( null, addr.trim() ); } msg.addPostmaster( CommonUIConfigManager.getConfigurationProperty( EIAppsPropertyKeys.EMAIL_POSTMASTER_NAME ), new InternetAddress( CommonUIConfigManager.getConfigurationProperty( EIAppsPropertyKeys.EMAIL_POSTMASTER_ADDRESS ) ) ); } catch ( AddressException a ) { logger.warn( "Ill-formed email address", a ); throw new ExternalServiceException(a, ExternalServiceExceptionType.FAILED_ACTION); } // this, too, of course, may throw ExternalServiceException: emailService.sendEmail( msg ); }