aCharset, bSSLEnabled, EmailGlobalSettings.isUseSTARTTLS (), EmailGlobalSettings.getConnectionTimeoutMilliSecs (), EmailGlobalSettings.getTimeoutMilliSecs (), EmailGlobalSettings.isDebugSMTP ());
@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; }
/** * 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 ()); }
.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 ())
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))
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 ());
for (final ConnectionListener aConnectionListener : EmailGlobalSettings.getAllConnectionListeners ()) aTransport.addConnectionListener (aConnectionListener); final ICommonsList <IEmailDataTransportListener> aEmailDataTransportListeners = EmailGlobalSettings.getAllEmailDataTransportListeners (); if (EmailGlobalSettings.isDebugSMTP ()) LOGGER.error ("Error send mail - SendFailedException", ex); if (EmailGlobalSettings.isDebugSMTP ()) LOGGER.error ("Error send mail - MessagingException", ex);
.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 ())
final Charset aCharset = CharsetHelper.getCharsetFromNameOrNull (sCharset); 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 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 ());
final Charset aCharset = CharsetHelper.getCharsetFromNameOrNull (sCharset); 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 ());
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 (new HCCheckBox (new RequestFieldBoolean (FIELD_STARTTLS, aSettings == null ? EmailGlobalSettings.isUseSTARTTLS () : aSettings.isSTARTTLSEnabled ()))) .setErrorList (aFormErrors.getListOfField (FIELD_STARTTLS))); aForm.addFormGroup (new BootstrapFormGroup ().setLabelMandatory (sConnectionTimeout) .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_CONNECTION_TIMEOUT, aSettings == null ? EmailGlobalSettings.getConnectionTimeoutMilliSecs () : aSettings.getConnectionTimeoutMilliSecs ()), aDisplayLocale).setMin (0) aForm.addFormGroup (new BootstrapFormGroup ().setLabelMandatory (sSocketTimeout) .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_SOCKET_TIMEOUT, aSettings == null ? EmailGlobalSettings.getTimeoutMilliSecs () : aSettings.getTimeoutMilliSecs ()), aDisplayLocale).setMin (0) aForm.addFormGroup (new BootstrapFormGroup ().setLabel (sDebugSMTP) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_DEBUG_SMTP, aSettings == null ? EmailGlobalSettings.isDebugSMTP () : aSettings.isDebugSMTP ()))) .setErrorList (aFormErrors.getListOfField (FIELD_DEBUG_SMTP)));
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 (new HCCheckBox (new RequestFieldBoolean (FIELD_STARTTLS, aSettings == null ? EmailGlobalSettings.isUseSTARTTLS () : aSettings.isSTARTTLSEnabled ()))) .setErrorList (aFormErrors.getListOfField (FIELD_STARTTLS))); aForm.addFormGroup (new BootstrapFormGroup ().setLabelMandatory (sConnectionTimeout) .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_CONNECTION_TIMEOUT, aSettings == null ? EmailGlobalSettings.getConnectionTimeoutMilliSecs () : aSettings.getConnectionTimeoutMilliSecs ()), aDisplayLocale).setMin (0) aForm.addFormGroup (new BootstrapFormGroup ().setLabelMandatory (sSocketTimeout) .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_SOCKET_TIMEOUT, aSettings == null ? EmailGlobalSettings.getTimeoutMilliSecs () : aSettings.getTimeoutMilliSecs ()), aDisplayLocale).setMin (0) aForm.addFormGroup (new BootstrapFormGroup ().setLabel (sDebugSMTP) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_DEBUG_SMTP, aSettings == null ? EmailGlobalSettings.isDebugSMTP () : aSettings.isDebugSMTP ()))) .setErrorList (aFormErrors.getListOfField (FIELD_DEBUG_SMTP)));
.setLabel (sSSL) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_SSL, aSettings == null ? EmailGlobalSettings.isUseSSL () : aSettings.isSSLEnabled ()))) .setErrorList (aFormErrors.getListOfField (FIELD_SSL)); .setLabel (sSTARTTLS) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_STARTTLS, aSettings == null ? EmailGlobalSettings.isUseSTARTTLS () : aSettings.isSTARTTLSEnabled ()))) .setErrorList (aFormErrors.getListOfField (FIELD_STARTTLS)); .setLabelMandatory (sConnectionTimeout) .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_CONNECTION_TIMEOUT, aSettings == null ? EmailGlobalSettings.getConnectionTimeoutMilliSecs () : aSettings.getConnectionTimeoutMilliSecs ()), aDisplayLocale).setMin (0).setThousandSeparator ("")) .setLabelMandatory (sSocketTimeout) .setCtrl (new HCAutoNumericInt (new RequestField (FIELD_SOCKET_TIMEOUT, aSettings == null ? EmailGlobalSettings.getTimeoutMilliSecs () : aSettings.getTimeoutMilliSecs ()), aDisplayLocale).setMin (0).setThousandSeparator ("")) .setLabel (sDebugSMTP) .setCtrl (new HCCheckBox (new RequestFieldBoolean (FIELD_DEBUG_SMTP, aSettings == null ? EmailGlobalSettings.isDebugSMTP () : aSettings.isDebugSMTP ()))) .setErrorList (aFormErrors.getListOfField (FIELD_DEBUG_SMTP));