/** * Constructor with default port, and no authentication * * @param sHost * SMTP server name or IP address. May neither be <code>null</code> nor * empty. */ public SMTPSettings (@Nonnull final String sHost) { this (sHost, -1, null, null, (Charset) null, EmailGlobalSettings.isUseSSL ()); }
aCharset, bSSLEnabled, EmailGlobalSettings.isUseSTARTTLS (), EmailGlobalSettings.getConnectionTimeoutMilliSecs (), EmailGlobalSettings.getTimeoutMilliSecs (), EmailGlobalSettings.isDebugSMTP ());
public HCNamedSMTPSettingsSelect (@Nonnull final IHCRequestField aRF, @Nonnull final List <NamedSMTPSettings> aSettings, @Nonnull final Locale aDisplayLocale) { super (aRF); for (final NamedSMTPSettings aCurObject : aSettings) { final ISMTPSettings aSMTP = aCurObject.getSMTPSettings (); String sUserName = ""; if (StringHelper.hasText (aSMTP.getUserName ())) sUserName = aSMTP.getUserName () + "@"; addOption (aCurObject.getID (), aCurObject.getName () + " (" + sUserName + aSMTP.getHostName () + ":" + aSMTP.getPort () + ")"); } addOptionPleaseSelect (aDisplayLocale); } }
.setCtrl (new HCEdit (new RequestField (FIELD_HOSTNAME, aSettings == null ? null : aSettings.getHostName ())).setPlaceholder (sHostName)) .setErrorList (aFormErrors.getListOfField (FIELD_HOSTNAME))); .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_PORT, aSettings != null && aSettings.hasPort () ? Integer.toString (aSettings.getPort ()) : ""), aDisplayLocale).setMin (CNetworkPort.MINIMUM_PORT_NUMBER) .setCtrl (new HCEdit (new RequestField (FIELD_USERNAME, aSettings == null ? null : aSettings.getUserName ())).setPlaceholder (sUserName)) .setErrorList (aFormErrors.getListOfField (FIELD_USERNAME))); .setCtrl (new HCCharsetSelect (new RequestField (FIELD_CHARSET, aSettings == null ? DEFAULT_CHARSET_NAME : aSettings.getCharsetName ()), true, aDisplayLocale)) aForm.addFormGroup (new BootstrapFormGroup ().setLabel (sSSL) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_SSL, aSettings == null ? EmailGlobalSettings.isUseSSL () : aSettings.isSSLEnabled ()))) .setErrorList (aFormErrors.getListOfField (FIELD_SSL))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (sSTARTTLS)
.setCtrl (Long.toString (EmailGlobalSettings.getMaxMailQueueLength ()))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_MAX_SEND_COUNT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getMaxMailSendCount ()))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_USE_SSL.getDisplayText (aDisplayLocale)) .setCtrl (EPhotonCoreText.getYesOrNo (EmailGlobalSettings.isUseSSL (), aDisplayLocale))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_USE_STARTTLS.getDisplayText (aDisplayLocale)) .setCtrl (EPhotonCoreText.getYesOrNo (EmailGlobalSettings.isUseSTARTTLS (), aDisplayLocale))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_CONNECTION_TIMEOUT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getConnectionTimeoutMilliSecs ()) + "ms")); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_SOCKET_TIMEOUT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getTimeoutMilliSecs ()) + "ms")); for (final ConnectionListener aListener : EmailGlobalSettings.getAllConnectionListeners ()) aCtrl.addChild (new HCDiv ().addChild (String.valueOf (aListener))); if (!aCtrl.hasChildren ()) for (final IEmailDataTransportListener aListener : EmailGlobalSettings.getAllEmailDataTransportListeners ()) aCtrl.addChild (new HCDiv ().addChild (String.valueOf (aListener))); if (!aCtrl.hasChildren ())
for (final ConnectionListener aConnectionListener : EmailGlobalSettings.getAllConnectionListeners ()) aTransport.addConnectionListener (aConnectionListener); final ICommonsList <IEmailDataTransportListener> aEmailDataTransportListeners = EmailGlobalSettings.getAllEmailDataTransportListeners (); aTransport.connect (m_aSMTPSettings.getHostName (), m_aSMTPSettings.getPort (), m_aSMTPSettings.getUserName (), m_aSMTPSettings.getPassword ()); MailConverter.fillMimeMessage (aMimeMessage, aEmailData, m_aSMTPSettings.getCharsetObj ()); if (EmailGlobalSettings.isDebugSMTP ()) LOGGER.error ("Error send mail - SendFailedException", ex); aDetails.add (new MailSendDetails (false, ssfe.getAddress ().toString (), ssfe.getCommand (), ssfe.getMessage ().trim (), ESMTPErrorCode.getFromIDOrDefault (ssfe.getReturnCode (), ESMTPErrorCode.FALLBACK))); aDetails.add (new MailSendDetails (true, ssfe.getAddress ().toString (), ssfe.getCommand (), ssfe.getMessage ().trim (), ESMTPErrorCode.getFromIDOrDefault (ssfe.getReturnCode (), ESMTPErrorCode.FALLBACK)));
final IEmailData aEmailData = aSelectedObject.getEmailData (); final Throwable aError = aSelectedObject.getError (); aTable.createItemRow ().setLabel (EText.MSG_ID.getDisplayText (aDisplayLocale)).setCtrl (aSelectedObject.getID ()); aTable.createItemRow () .setLabel (EText.MSG_ERROR_DT.getDisplayText (aDisplayLocale)) .setCtrl (aSelectedObject.getErrorTimeDisplayText (aDisplayLocale)); aTable.createItemRow () .setLabel (EText.MSG_SMTP_SETTINGS.getDisplayText (aDisplayLocale)) .setCtrl (aSelectedObject.getSMTPServerDisplayText ()); aTable.createItemRow () .setLabel (EText.MSG_SENDING_DT.getDisplayText (aDisplayLocale)) .setCtrl (PDTToString.getAsString (aSelectedObject.getOriginalSentDateTime (), aDisplayLocale)); if (aEmailData != null) .setCtrl (aEmailData.getEmailType ().getID ()); .setCtrl (aEmailData.getFrom ().getDisplayName ()); final IHCNode aReplyTo = _getAsString (aEmailData.getReplyTo ()); if (aReplyTo != null) aTable.createItemRow ().setLabel (EText.MSG_REPLY_TO.getDisplayText (aDisplayLocale)).setCtrl (aReplyTo); .setCtrl (_getAsString (aEmailData.getTo ())); final IHCNode aCc = _getAsString (aEmailData.getCc ()); if (aCc != null) aTable.createItemRow ().setLabel (EText.MSG_CC.getDisplayText (aDisplayLocale)).setCtrl (aCc);
aTable.createItemRow () .setLabelMandatory (sHostName) .setCtrl (new HCEdit (new RequestField (FIELD_HOSTNAME, aSettings == null ? null : aSettings.getHostName ())).setPlaceholder (sHostName)) .setErrorList (aFormErrors.getListOfField (FIELD_HOSTNAME)); .setLabelMandatory (sPort) .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_PORT, aSettings == null || aSettings.getPort () < 0 ? "" : Integer.toString (aSettings.getPort ())), aDisplayLocale).setMin (CNetworkPort.MINIMUM_PORT_NUMBER) .setMax (CNetworkPort.MAXIMUM_PORT_NUMBER) aTable.createItemRow () .setLabel (sUserName) .setCtrl (new HCEdit (new RequestField (FIELD_USERNAME, aSettings == null ? null : aSettings.getUserName ())).setPlaceholder (sUserName)) .setErrorList (aFormErrors.getListOfField (FIELD_USERNAME)); .setLabelMandatory (sCharset) .setCtrl (new HCCharsetSelect (new RequestField (FIELD_CHARSET, aSettings == null ? DEFAULT_CHARSET : aSettings.getCharset ()), true, aDisplayLocale)) .setLabel (sSSL) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_SSL, aSettings == null ? EmailGlobalSettings.isUseSSL () : aSettings.isSSLEnabled ()))) .setErrorList (aFormErrors.getListOfField (FIELD_SSL));
aTable.createItemRow () .setLabel (EText.MSG_EMAIL_MAILQUEUE_LENGTH.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getMaxMailQueueLength ())); aTable.createItemRow () .setLabel (EText.MSG_EMAIL_MAX_SEND_COUNT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getMaxMailSendCount ())); aTable.createItemRow () .setLabel (EText.MSG_EMAIL_USE_SSL.getDisplayText (aDisplayLocale)) .setCtrl (EWebBasicsText.getYesOrNo (EmailGlobalSettings.isUseSSL (), aDisplayLocale)); aTable.createItemRow () .setLabel (EText.MSG_EMAIL_USE_STARTTLS.getDisplayText (aDisplayLocale)) .setCtrl (EWebBasicsText.getYesOrNo (EmailGlobalSettings.isUseSTARTTLS (), aDisplayLocale)); aTable.createItemRow () .setLabel (EText.MSG_EMAIL_CONNECTION_TIMEOUT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getConnectionTimeoutMilliSecs ()) + "ms"); aTable.createItemRow () .setLabel (EText.MSG_EMAIL_SOCKET_TIMEOUT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getTimeoutMilliSecs ()) + "ms"); aTable.createItemRow () .setLabel (EText.MSG_EMAIL_CONNECTION_LISTENER.getDisplayText (aDisplayLocale)) .setCtrl (EmailGlobalSettings.getConnectionListener () == null ? HCEM.create (EText.MSG_NONE.getDisplayText (aDisplayLocale)) : new HCTextNode (String.valueOf (EmailGlobalSettings.getConnectionListener ()))); aTable.createItemRow () .setLabel (EText.MSG_EMAIL_TRANSPORT_LISTENER.getDisplayText (aDisplayLocale)) .setCtrl (EmailGlobalSettings.getTransportListener () == null ? HCEM.create (EText.MSG_NONE.getDisplayText (aDisplayLocale)) : new HCTextNode (String.valueOf (EmailGlobalSettings.getTransportListener ()))); aTable.createItemRow () .setLabel (EText.MSG_EMAIL_EMAILDATA_TRANSPORT_LISTENER.getDisplayText (aDisplayLocale)) .setCtrl (EmailGlobalSettings.getEmailDataTransportListener () == null ? HCEM.create (EText.MSG_NONE.getDisplayText (aDisplayLocale))
sPassword = aSelectedObject.getSMTPSettings ().getPassword (); final boolean bSSLEnabled = aWPEC.params ().isCheckBoxChecked (FIELD_SSL, EmailGlobalSettings.isUseSSL ()); final boolean bSTARTTLSEnabled = aWPEC.params () .isCheckBoxChecked (FIELD_STARTTLS, EmailGlobalSettings.isUseSTARTTLS ()); final long nConnectionTimeoutMS = aWPEC.params ().getAsLong (FIELD_CONNECTION_TIMEOUT, CGlobal.ILLEGAL_ULONG); final long nSocketTimeoutMS = aWPEC.params ().getAsLong (FIELD_SOCKET_TIMEOUT, CGlobal.ILLEGAL_ULONG); final boolean bDebugSMTP = aWPEC.params ().isCheckBoxChecked (FIELD_DEBUG_SMTP, EmailGlobalSettings.isDebugSMTP ()); final SMTPSettings aSMTPSettings = new SMTPSettings (sHostName, nPort, sUserName,
final boolean bSSLEnabled = StringParser.parseBool (sSSLEnabled, EmailGlobalSettings.isUseSSL ()); final boolean bSTARTTLSEnabled = StringParser.parseBool (sSTARTTLSEnabled, EmailGlobalSettings.isUseSTARTTLS ()); EmailGlobalSettings.getConnectionTimeoutMilliSecs ()); EmailGlobalSettings.getTimeoutMilliSecs ()); final boolean bDebugSMTP = StringParser.parseBool (sDebugSMTP, EmailGlobalSettings.isDebugSMTP ()); return new SMTPSettings (sHost, nPort, sUser,
final boolean bDisabled = m_aFailedMailQueue.getAllFailedMails ().isEmpty (); final IButtonToolbar <?> aToolbar = getStyler ().createToolbar (aWPEC); aToolbar.addButton (EWebBasicsText.MSG_BUTTON_REFRESH.getDisplayText (aDisplayLocale), EText.MSG_ERROR.getDisplayText (aDisplayLocale)); for (final FailedMailData aItem : m_aFailedMailQueue.getAllFailedMails ()) final IEmailData aEmailData = aItem.getEmailData (); final Throwable aError = aItem.getError (); aRow.addCell (new HCA (aViewURL).addChild (aItem.getID ())); aRow.addCell (aItem.getErrorTimeDisplayText (aDisplayLocale)); aRow.addCell (aItem.getSMTPServerDisplayText ()); aRow.addCell (aEmailData == null ? null : aEmailData.getSubject ()); aRow.addCell (aError == null ? null : aError.getMessage ());
sPassword = aSelectedObject.getSMTPSettings ().getPassword (); final boolean bSSLEnabled = aWPEC.getCheckBoxAttr (FIELD_SSL, EmailGlobalSettings.isUseSSL ()); final boolean bSTARTTLSEnabled = aWPEC.getCheckBoxAttr (FIELD_STARTTLS, EmailGlobalSettings.isUseSTARTTLS ()); final long nConnectionTimeoutMS = aWPEC.getAttributeAsLong (FIELD_CONNECTION_TIMEOUT, CGlobal.ILLEGAL_ULONG); final long nSocketTimeoutMS = aWPEC.getAttributeAsLong (FIELD_SOCKET_TIMEOUT, CGlobal.ILLEGAL_ULONG); final boolean bDebugSMTP = aWPEC.getCheckBoxAttr (FIELD_DEBUG_SMTP, EmailGlobalSettings.isDebugSMTP ()); final ReadonlySMTPSettings aSMTPSettings = new ReadonlySMTPSettings (sHostName, nPort, sUserName,
@Nonnull @MustBeLocked (ELockType.WRITE) private static MailQueuePerSMTP _getOrCreateMailQueuePerSMTP (@Nonnull final ISMTPSettings aSMTPSettings) { ValueEnforcer.notNull (aSMTPSettings, "SmtpSettings"); if (s_aSenderThreadPool.isShutdown ()) throw new IllegalStateException ("Cannot submit to mailqueues that are already stopped!"); // get queue per SMTP MailQueuePerSMTP aSMTPQueue = s_aQueueCache.get (aSMTPSettings); if (aSMTPQueue == null) { // create a new queue aSMTPQueue = new MailQueuePerSMTP (EmailGlobalSettings.getMaxMailQueueLength (), EmailGlobalSettings.getMaxMailSendCount (), aSMTPSettings, s_aFailedMailQueue); // put queue in cache s_aQueueCache.put (aSMTPSettings, aSMTPQueue); // and start running the queue s_aSenderThreadPool.submit (aSMTPQueue::collect); } return aSMTPQueue; }
.setCtrl (aSettings.getHostName ()); .setCtrl (aSettings.getPort () > 0 ? Integer.toString (aSettings.getPort ()) : EText.PORT_DEFAULT.getDisplayText (aDisplayLocale)); .setCtrl (aSettings.getUserName ()); .setCtrl (StringHelper.hasText (aSettings.getPassword ()) ? "***" : EText.MSG_NO_PASSWORD_SET.getDisplayText (aDisplayLocale)); .setCtrl (aSettings.getCharset ()); .setCtrl (EWebBasicsText.getYesOrNo (aSettings.isSSLEnabled (), aDisplayLocale)); .setCtrl (EWebBasicsText.getYesOrNo (aSettings.isSTARTTLSEnabled (), aDisplayLocale)); .setCtrl (Long.toString (aSettings.getConnectionTimeoutMilliSecs ())); .setCtrl (Long.toString (aSettings.getTimeoutMilliSecs ()));
/** * Init the default global settings. This is called after init of the global * ID factory. */ protected final void initDefaultGlobalSettings () { // Enable when ready WebScopeManager.setSessionPassivationAllowed (false); // Define the password constrains GlobalPasswordSettings.setPasswordConstraintList (new PasswordConstraintList (new PasswordConstraintMinLength (DEFAULT_PASSWORD_MIN_LENGTH))); // Email global settings EmailGlobalSettings.addEmailDataTransportListener (new AuditingEmailDataTransportListener ()); if (GlobalDebug.isDebugMode ()) { EmailGlobalSettings.addConnectionListener (new LoggingConnectionListener ()); } else { // HTML output settings HCSettings.getMutableConversionSettings ().setToOptimized (); // Disable CSS Value consistency checks CSSValue.setConsistencyChecksEnabled (false); } }
.setCtrl (new HCEdit (new RequestField (FIELD_HOSTNAME, aSettings == null ? null : aSettings.getHostName ())).setPlaceholder (sHostName)) .setErrorList (aFormErrors.getListOfField (FIELD_HOSTNAME))); .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_PORT, aSettings != null && aSettings.hasPort () ? Integer.toString (aSettings.getPort ()) : ""), aDisplayLocale).setMin (CNetworkPort.MINIMUM_PORT_NUMBER) .setCtrl (new HCEdit (new RequestField (FIELD_USERNAME, aSettings == null ? null : aSettings.getUserName ())).setPlaceholder (sUserName)) .setErrorList (aFormErrors.getListOfField (FIELD_USERNAME))); .setCtrl (new HCCharsetSelect (new RequestField (FIELD_CHARSET, aSettings == null ? DEFAULT_CHARSET_NAME : aSettings.getCharsetName ()), true, aDisplayLocale)) aForm.addFormGroup (new BootstrapFormGroup ().setLabel (sSSL) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_SSL, aSettings == null ? EmailGlobalSettings.isUseSSL () : aSettings.isSSLEnabled ()))) .setErrorList (aFormErrors.getListOfField (FIELD_SSL))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (sSTARTTLS)
.setCtrl (Long.toString (EmailGlobalSettings.getMaxMailQueueLength ()))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_MAX_SEND_COUNT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getMaxMailSendCount ()))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_USE_SSL.getDisplayText (aDisplayLocale)) .setCtrl (EPhotonCoreText.getYesOrNo (EmailGlobalSettings.isUseSSL (), aDisplayLocale))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_USE_STARTTLS.getDisplayText (aDisplayLocale)) .setCtrl (EPhotonCoreText.getYesOrNo (EmailGlobalSettings.isUseSTARTTLS (), aDisplayLocale))); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_CONNECTION_TIMEOUT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getConnectionTimeoutMilliSecs ()) + "ms")); aForm.addFormGroup (new BootstrapFormGroup ().setLabel (EText.MSG_EMAIL_SOCKET_TIMEOUT.getDisplayText (aDisplayLocale)) .setCtrl (Long.toString (EmailGlobalSettings.getTimeoutMilliSecs ()) + "ms")); for (final ConnectionListener aListener : EmailGlobalSettings.getAllConnectionListeners ()) aCtrl.addChild (new HCDiv ().addChild (String.valueOf (aListener))); if (!aCtrl.hasChildren ()) for (final IEmailDataTransportListener aListener : EmailGlobalSettings.getAllEmailDataTransportListeners ()) aCtrl.addChild (new HCDiv ().addChild (String.valueOf (aListener))); if (!aCtrl.hasChildren ())
sPassword = aSelectedObject.getSMTPSettings ().getPassword (); final boolean bSSLEnabled = aWPEC.params ().isCheckBoxChecked (FIELD_SSL, EmailGlobalSettings.isUseSSL ()); final boolean bSTARTTLSEnabled = aWPEC.params () .isCheckBoxChecked (FIELD_STARTTLS, EmailGlobalSettings.isUseSTARTTLS ()); final long nConnectionTimeoutMS = aWPEC.params ().getAsLong (FIELD_CONNECTION_TIMEOUT, CGlobal.ILLEGAL_ULONG); final long nSocketTimeoutMS = aWPEC.params ().getAsLong (FIELD_SOCKET_TIMEOUT, CGlobal.ILLEGAL_ULONG); final boolean bDebugSMTP = aWPEC.params ().isCheckBoxChecked (FIELD_DEBUG_SMTP, EmailGlobalSettings.isDebugSMTP ()); final SMTPSettings aSMTPSettings = new SMTPSettings (sHostName, nPort, sUserName,
aRow.addCell (aSettings.getHostName () + (aSettings.getPort () > 0 ? ":" + aSettings.getPort () : "")); aRow.addCell (aSettings.getUserName ());