Explorar o código

Initial multiple email server implemintation

rkeil %!s(int64=7) %!d(string=hai) anos
pai
achega
233d5c1e15

+ 9 - 7
server/src/main/java/password/pwm/config/Configuration.java

@@ -1048,13 +1048,11 @@ public class Configuration implements SettingReader
     /* generic profile stuff */
     /* generic profile stuff */
 
 
 
 
-    public Map<String, NewUserProfile> getNewUserProfiles( )
-    {
-        final Map<String, NewUserProfile> returnMap = new LinkedHashMap<>();
-        final Map<String, Profile> profileMap = profileMap( ProfileType.NewUser );
-        for ( final Map.Entry<String, Profile> entry : profileMap.entrySet() )
-        {
-            returnMap.put( entry.getKey(), ( NewUserProfile ) entry.getValue() );
+    public Map<String,NewUserProfile> getNewUserProfiles() {
+        final Map<String,NewUserProfile> returnMap = new LinkedHashMap<>();
+        final Map<String,Profile> profileMap = profileMap(ProfileType.NewUser);
+        for (final Map.Entry<String,Profile> entry : profileMap.entrySet()) {
+            returnMap.put(entry.getKey(), (NewUserProfile) entry.getValue());
         }
         }
         return returnMap;
         return returnMap;
     }
     }
@@ -1142,6 +1140,10 @@ public class Configuration implements SettingReader
                 newProfile = DeleteAccountProfile.makeFromStoredConfiguration( storedConfiguration, profileID );
                 newProfile = DeleteAccountProfile.makeFromStoredConfiguration( storedConfiguration, profileID );
                 break;
                 break;
 
 
+            case EmailServers:
+                newProfile = EmailServerProfile.makeFromStoredConfiguration(storedConfiguration, profileID);
+                break;
+
             case SetupOTPProfile:
             case SetupOTPProfile:
                 newProfile = SetupOtpProfile.makeFromStoredConfiguration( storedConfiguration, profileID );
                 newProfile = SetupOtpProfile.makeFromStoredConfiguration( storedConfiguration, profileID );
                 break;
                 break;

+ 5 - 5
server/src/main/java/password/pwm/config/PwmSetting.java

@@ -283,7 +283,7 @@ public enum PwmSetting
             "email.profile.list", PwmSettingSyntax.PROFILE, PwmSettingCategory.INTERNAL),
             "email.profile.list", PwmSettingSyntax.PROFILE, PwmSettingCategory.INTERNAL),
     EMAIL_SERVER_ADDRESSES(
     EMAIL_SERVER_ADDRESSES(
             "email.smtp.addresses", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_PROFILES),
             "email.smtp.addresses", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_PROFILES),
-    EMAIL_SERVER_PORTs(
+    EMAIL_SERVER_PORTS(
             "email.smtp.ports", PwmSettingSyntax.NUMERIC, PwmSettingCategory.EMAIL_PROFILES),
             "email.smtp.ports", PwmSettingSyntax.NUMERIC, PwmSettingCategory.EMAIL_PROFILES),
     EMAIL_DEFAULT_FROM_ADDRESSES(
     EMAIL_DEFAULT_FROM_ADDRESSES(
             "email.default.fromAddresses", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_PROFILES),
             "email.default.fromAddresses", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_PROFILES),
@@ -302,7 +302,8 @@ public enum PwmSetting
     EMAIL_USERNAME(
     EMAIL_USERNAME(
             "email.smtp.username", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_SETTINGS ),
             "email.smtp.username", PwmSettingSyntax.STRING, PwmSettingCategory.EMAIL_SETTINGS ),
     EMAIL_PASSWORD(
     EMAIL_PASSWORD(
-            "email.smtp.userpassword", PwmSettingSyntax.PASSWORD, PwmSettingCategory.EMAIL_SETTINGS ),
+            "email.smtp.userpassword", PwmSettingSyntax.PASSWORD, PwmSettingCategory.EMAIL_SETTINGS),
+
     EMAIL_MAX_QUEUE_AGE(
     EMAIL_MAX_QUEUE_AGE(
             "email.queueMaxAge", PwmSettingSyntax.DURATION, PwmSettingCategory.EMAIL_SETTINGS ),
             "email.queueMaxAge", PwmSettingSyntax.DURATION, PwmSettingCategory.EMAIL_SETTINGS ),
     EMAIL_ADVANCED_SETTINGS(
     EMAIL_ADVANCED_SETTINGS(
@@ -681,9 +682,8 @@ public enum PwmSetting
     AUDIT_SYSLOG_SERVERS(
     AUDIT_SYSLOG_SERVERS(
             "audit.syslog.servers", PwmSettingSyntax.STRING_ARRAY, PwmSettingCategory.AUDIT_FORWARD ),
             "audit.syslog.servers", PwmSettingSyntax.STRING_ARRAY, PwmSettingCategory.AUDIT_FORWARD ),
     AUDIT_SYSLOG_CERTIFICATES(
     AUDIT_SYSLOG_CERTIFICATES(
-            "audit.syslog.certificates", PwmSettingSyntax.X509CERT, PwmSettingCategory.AUDIT_FORWARD ),
-    AUDIT_SYSLOG_OUTPUT_FORMAT(
-            "audit.syslog.outputFormat", PwmSettingSyntax.SELECT, PwmSettingCategory.AUDIT_FORWARD ),
+            "audit.syslog.certificates", PwmSettingSyntax.X509CERT, PwmSettingCategory.AUDIT_FORWARD),
+
 
 
     // challenge settings
     // challenge settings
     CHALLENGE_ENABLE(
     CHALLENGE_ENABLE(

+ 9 - 9
server/src/main/java/password/pwm/config/profile/ProfileType.java

@@ -25,15 +25,15 @@ package password.pwm.config.profile;
 import password.pwm.config.PwmSetting;
 import password.pwm.config.PwmSetting;
 import password.pwm.config.PwmSettingCategory;
 import password.pwm.config.PwmSettingCategory;
 
 
-public enum ProfileType
-{
-    Helpdesk( true, PwmSettingCategory.HELPDESK_PROFILE, PwmSetting.HELPDESK_PROFILE_QUERY_MATCH ),
-    ForgottenPassword( false, PwmSettingCategory.RECOVERY_PROFILE, PwmSetting.RECOVERY_PROFILE_QUERY_MATCH ),
-    NewUser( false, PwmSettingCategory.NEWUSER_PROFILE, null ),
-    UpdateAttributes( true, PwmSettingCategory.UPDATE_PROFILE, PwmSetting.UPDATE_PROFILE_QUERY_MATCH ),
-    DeleteAccount( true, PwmSettingCategory.DELETE_ACCOUNT_PROFILE, PwmSetting.DELETE_ACCOUNT_PERMISSION ),
-    SetupOTPProfile( true, PwmSettingCategory.OTP_PROFILE, PwmSetting.OTP_SETUP_USER_PERMISSION ),;
-
+public enum ProfileType {
+    Helpdesk            (true,  PwmSettingCategory.HELPDESK_PROFILE,    PwmSetting.HELPDESK_PROFILE_QUERY_MATCH),
+    ForgottenPassword   (false, PwmSettingCategory.RECOVERY_PROFILE,    PwmSetting.RECOVERY_PROFILE_QUERY_MATCH),
+    NewUser             (false, PwmSettingCategory.NEWUSER_PROFILE,     null),
+    UpdateAttributes    (true,  PwmSettingCategory.UPDATE_PROFILE,      PwmSetting.UPDATE_PROFILE_QUERY_MATCH),
+    DeleteAccount(true,  PwmSettingCategory.DELETE_ACCOUNT_PROFILE, PwmSetting.DELETE_ACCOUNT_PERMISSION),
+    EmailServers(true, PwmSettingCategory.EMAIL_PROFILES, null),
+    ;
+    
     private final boolean authenticated;
     private final boolean authenticated;
     private final PwmSettingCategory category;
     private final PwmSettingCategory category;
     private final PwmSetting queryMatch;
     private final PwmSetting queryMatch;

+ 124 - 9
server/src/main/java/password/pwm/http/servlet/forgottenpw/ForgottenPasswordServlet.java

@@ -1091,14 +1091,9 @@ public class ForgottenPasswordServlet extends ControlledPwmServlet
 
 
         LOGGER.trace( pwmRequest, "all recovery checks passed, proceeding to configured recovery action" );
         LOGGER.trace( pwmRequest, "all recovery checks passed, proceeding to configured recovery action" );
 
 
-        final RecoveryAction recoveryAction = ForgottenPasswordUtil.getRecoveryAction( config, forgottenPasswordBean );
-        if ( recoveryAction == RecoveryAction.SENDNEWPW || recoveryAction == RecoveryAction.SENDNEWPW_AND_EXPIRE )
-        {
-            if ( disallowAllButUnlock )
-            {
-                PasswordUtility.throwPasswordTooSoonException( userInfo, pwmRequest.getSessionLabel() );
-            }
-            ForgottenPasswordUtil.doActionSendNewPassword( pwmRequest );
+        final RecoveryAction recoveryAction = ForgottenPasswordUtil.getRecoveryAction(config, forgottenPasswordBean);
+        if (recoveryAction == RecoveryAction.SENDNEWPW || recoveryAction == RecoveryAction.SENDNEWPW_AND_EXPIRE) {
+            processSendNewPassword(pwmRequest);
             return;
             return;
         }
         }
 
 
@@ -1221,8 +1216,128 @@ public class ForgottenPasswordServlet extends ControlledPwmServlet
         }
         }
     }
     }
 
 
+    private static void processSendNewPassword(final PwmRequest pwmRequest)
+            throws ChaiUnavailableException, IOException, ServletException, PwmUnrecoverableException
+    {
+        final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
+        final PwmSession pwmSession = pwmRequest.getPwmSession();
+        final ForgottenPasswordBean forgottenPasswordBean = forgottenPasswordBean(pwmRequest);
+        final ForgottenPasswordProfile forgottenPasswordProfile = forgottenPasswordProfile(pwmRequest);
+        final RecoveryAction recoveryAction = ForgottenPasswordUtil.getRecoveryAction(pwmApplication.getConfig(), forgottenPasswordBean);
+
+        LOGGER.trace(pwmRequest,"beginning process to send new password to user");
+
+        if (!forgottenPasswordBean.getProgress().isAllPassed()) {
+            return;
+        }
+
+        final UserIdentity userIdentity = forgottenPasswordBean.getUserIdentity();
+        final ChaiUser theUser = pwmRequest.getPwmApplication().getProxiedChaiUser(userIdentity);
+
+        try { // try unlocking user
+            theUser.unlockPassword();
+            LOGGER.trace(pwmRequest, "unlock account succeeded");
+        } catch (ChaiOperationException e) {
+            final String errorMsg = "unable to unlock user " + theUser.getEntryDN() + " error: " + e.getMessage();
+            final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNLOCK_FAILURE,errorMsg);
+            LOGGER.error(pwmRequest.getPwmSession(), errorInformation.toDebugStr());
+            pwmRequest.respondWithError(errorInformation);
+            return;
+        }
+
+        try {
+            pwmSession.getLoginInfoBean().setAuthenticated(true);
+            pwmSession.getLoginInfoBean().getAuthFlags().add(AuthenticationType.AUTH_FROM_PUBLIC_MODULE);
+            pwmSession.getLoginInfoBean().setUserIdentity(userIdentity);
+
+            LOGGER.info(pwmRequest, "user successfully supplied password recovery responses, emailing new password to: " + theUser.getEntryDN());
+
+            // add post change actions
+            addPostChangeAction(pwmRequest, userIdentity);
+
+            // create newpassword
+            final PasswordData newPassword = RandomPasswordGenerator.createRandomPassword(pwmSession, pwmApplication);
+
+            // set the password
+            LOGGER.trace(pwmRequest.getPwmSession(), "setting user password to system generated random value");
+            PasswordUtility.setActorPassword(pwmSession, pwmApplication, newPassword);
+
+            if (recoveryAction == RecoveryAction.SENDNEWPW_AND_EXPIRE) {
+                LOGGER.debug(pwmSession, "marking user password as expired");
+                theUser.expirePassword();
+            }
+
+            // mark the event log
+            pwmApplication.getAuditManager().submit(AuditEvent.RECOVER_PASSWORD, pwmSession.getUserInfo(), pwmSession);
+
+            final MessageSendMethod messageSendMethod = forgottenPasswordProfile.readSettingAsEnum(PwmSetting.RECOVERY_SENDNEWPW_METHOD,MessageSendMethod.class);
+
+            // send email or SMS
+            final String toAddress = PasswordUtility.sendNewPassword(
+                    pwmSession.getUserInfo(),
+                    pwmApplication,
+                    pwmSession.getSessionManager().getMacroMachine(pwmApplication),
+                    newPassword,
+                    pwmSession.getSessionStateBean().getLocale(),
+                    messageSendMethod
+            );
+
+            pwmRequest.getPwmResponse().forwardToSuccessPage(Message.Success_PasswordSend, toAddress);
+        } catch (PwmException e) {
+            LOGGER.warn(pwmSession,"unexpected error setting new password during recovery process for user: " + e.getMessage());
+            pwmRequest.respondWithError(e.getErrorInformation());
+        } catch (ChaiOperationException e) {
+            final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN,"unexpected ldap error while processing recovery action " + recoveryAction + ", error: " + e.getMessage());
+            LOGGER.warn(pwmSession,errorInformation.toDebugStr());
+            pwmRequest.respondWithError(errorInformation);
+        } finally {
+            clearForgottenPasswordBean(pwmRequest);
+            pwmSession.unauthenticateUser(pwmRequest);
+            pwmSession.getSessionStateBean().setPasswordModified(false);
+        }
+    }
+
+
+    private static List<FormConfiguration> figureAttributeForm(
+            final ForgottenPasswordProfile forgottenPasswordProfile,
+            final ForgottenPasswordBean forgottenPasswordBean,
+            final PwmRequest pwmRequest,
+            final UserIdentity userIdentity
+    )
+            throws ChaiUnavailableException, PwmOperationalException, PwmUnrecoverableException
+    {
+        final List<FormConfiguration> requiredAttributesForm = forgottenPasswordProfile.readSettingAsForm(PwmSetting.RECOVERY_ATTRIBUTE_FORM);
+        if (requiredAttributesForm.isEmpty()) {
+            return requiredAttributesForm;
+        }
+
+        final UserInfo userInfo = ForgottenPasswordUtil.readUserInfo(pwmRequest, forgottenPasswordBean);
+        final List<FormConfiguration> returnList = new ArrayList<>();
+        for (final FormConfiguration formItem : requiredAttributesForm) {
+            if (formItem.isRequired()) {
+                returnList.add(formItem);
+            } else {
+                try {
+                    final String currentValue = userInfo.readStringAttribute(formItem.getName());
+                    if (currentValue != null && currentValue.length() > 0) {
+                        returnList.add(formItem);
+                    } else {
+                        LOGGER.trace(pwmRequest, "excluding optional required attribute(" + formItem.getName() + "), user has no value");
+                    }
+                } catch (PwmUnrecoverableException e) {
+                    throw new PwmOperationalException(new ErrorInformation(PwmError.ERROR_NO_CHALLENGES, "unexpected error reading value for attribute " + formItem.getName()));
+                }
+            }
+        }
+
+        if (returnList.isEmpty()) {
+            throw new PwmOperationalException(new ErrorInformation(PwmError.ERROR_NO_CHALLENGES, "user has no values for any optional attribute"));
+        }
+
+        return returnList;
+    }
 
 
-    static void addPostChangeAction(
+    private static void addPostChangeAction(
             final PwmRequest pwmRequest,
             final PwmRequest pwmRequest,
             final UserIdentity userIdentity
             final UserIdentity userIdentity
     )
     )

+ 103 - 25
server/src/main/java/password/pwm/util/queue/EmailQueueManager.java

@@ -27,9 +27,12 @@ import password.pwm.PwmApplication;
 import password.pwm.PwmApplicationMode;
 import password.pwm.PwmApplicationMode;
 import password.pwm.PwmConstants;
 import password.pwm.PwmConstants;
 import password.pwm.bean.EmailItemBean;
 import password.pwm.bean.EmailItemBean;
+import password.pwm.bean.pub.EmailServerBean;
 import password.pwm.config.Configuration;
 import password.pwm.config.Configuration;
 import password.pwm.config.PwmSetting;
 import password.pwm.config.PwmSetting;
+import password.pwm.config.StoredValue;
 import password.pwm.config.option.DataStorageMethod;
 import password.pwm.config.option.DataStorageMethod;
+import password.pwm.config.stored.StoredConfiguration;
 import password.pwm.error.ErrorInformation;
 import password.pwm.error.ErrorInformation;
 import password.pwm.error.PwmError;
 import password.pwm.error.PwmError;
 import password.pwm.error.PwmException;
 import password.pwm.error.PwmException;
@@ -83,6 +86,8 @@ public class EmailQueueManager implements PwmService
     private static final PwmLogger LOGGER = PwmLogger.forClass( EmailQueueManager.class );
     private static final PwmLogger LOGGER = PwmLogger.forClass( EmailQueueManager.class );
 
 
     private PwmApplication pwmApplication;
     private PwmApplication pwmApplication;
+    private List<EmailServerBean> emailServers = new ArrayList<EmailServerBean>();
+    private static List<EmailServerBean> staticEmailServers = new ArrayList<EmailServerBean>();
     private Properties javaMailProps = new Properties();
     private Properties javaMailProps = new Properties();
     private WorkQueueProcessor<EmailItemBean> workQueueProcessor;
     private WorkQueueProcessor<EmailItemBean> workQueueProcessor;
 
 
@@ -97,6 +102,61 @@ public class EmailQueueManager implements PwmService
         status = STATUS.OPENING;
         status = STATUS.OPENING;
         this.pwmApplication = pwmApplication;
         this.pwmApplication = pwmApplication;
         javaMailProps = makeJavaMailProps( pwmApplication.getConfig() );
         javaMailProps = makeJavaMailProps( pwmApplication.getConfig() );
+        String hostAddress = "";
+        String emailFromAddress = "";
+        String emailUsername = "";
+        PasswordData emailPassword = null;
+        int hostPort = 0;
+        boolean allAvailable = true;
+
+        final List<String> profiles = pwmApplication.getConfig().readSettingAsStringArray(PwmSetting.EMAIL_PROFILES);
+
+        try {
+            final StoredConfiguration storedConfiguration = pwmApplication.getConfig().getStoredConfiguration();
+
+            for (int i = 0; i < profiles.size(); i++) {
+                final String profileName = profiles.get(i);
+                final StoredValue address = storedConfiguration.readSetting(PwmSetting.EMAIL_SERVER_ADDRESSES, profileName);
+                if (null != address) {
+                    hostAddress = address.toString();
+                } else {
+                    allAvailable = false;
+                }
+                final StoredValue port = storedConfiguration.readSetting(PwmSetting.EMAIL_SERVER_PORTS, profileName);
+                if (null != port) {
+                    hostPort = Integer.parseInt(port.toString());
+                } else {
+                    allAvailable = false;
+                }
+                LOGGER.debug("Port value: " + port.toString());
+                final StoredValue fromAddress = storedConfiguration.readSetting(PwmSetting.EMAIL_DEFAULT_FROM_ADDRESSES, profileName);
+                if (null != fromAddress) {
+                    emailFromAddress = fromAddress.toString();
+                } else {
+                    allAvailable = false;
+                }
+                final StoredValue username = storedConfiguration.readSetting(PwmSetting.EMAIL_USERNAMES, profileName);
+                if (null != username) {
+                    emailUsername = username.toString();
+                } else {
+                    allAvailable = false;
+                }
+                final StoredValue mailPassword = storedConfiguration.readSetting(PwmSetting.EMAIL_PASSWORDS, profileName);
+                if (null != mailPassword) {
+                    emailPassword = Configuration.JavaTypeConverter.valueToPassword(mailPassword);
+                } else {
+                    allAvailable = false;
+                }
+                if (allAvailable) {
+                    final EmailServerBean emailServerBean = new EmailServerBean(hostAddress, hostPort, emailFromAddress, emailUsername, emailPassword, false);
+                    emailServers.add(emailServerBean);
+                }
+            }
+            staticEmailServers = emailServers;
+        } catch (PwmUnrecoverableException ure) {
+
+
+        }
 
 
         if ( pwmApplication.getLocalDB() == null || pwmApplication.getLocalDB().status() != LocalDB.Status.OPEN )
         if ( pwmApplication.getLocalDB() == null || pwmApplication.getLocalDB().status() != LocalDB.Status.OPEN )
         {
         {
@@ -198,14 +258,16 @@ public class EmailQueueManager implements PwmService
         }
         }
     }
     }
 
 
-    private boolean determineIfItemCanBeDelivered( final EmailItemBean emailItem )
-    {
-        final String serverAddress = pwmApplication.getConfig().readSettingAsString( PwmSetting.EMAIL_SERVER_ADDRESS );
+    private boolean determineIfItemCanBeDelivered(final EmailItemBean emailItem) {
 
 
-        if ( serverAddress == null || serverAddress.length() < 1 )
-        {
-            LOGGER.debug( "discarding email send event (no SMTP server address configured) " + emailItem.toDebugString() );
-            return false;
+        String serverAddress = "";
+
+        for (int i = 0; i < emailServers.size(); i++) {
+            serverAddress = emailServers.get(i).getServerAddress();if (serverAddress == null || serverAddress.length() < 1)
+        {    LOGGER.debug("discarding email send event (no SMTP server address configured) " + emailItem.toDebugString());
+            return false;} else {
+                break;
+            }
         }
         }
 
 
         if ( emailItem.getFrom() == null || emailItem.getFrom().length() < 1 )
         if ( emailItem.getFrom() == null || emailItem.getFrom().length() < 1 )
@@ -413,28 +475,40 @@ public class EmailQueueManager implements PwmService
     private Transport getSmtpTransport( )
     private Transport getSmtpTransport( )
             throws MessagingException, PwmUnrecoverableException
             throws MessagingException, PwmUnrecoverableException
     {
     {
-        final String mailUser = this.pwmApplication.getConfig().readSettingAsString( PwmSetting.EMAIL_USERNAME );
-        final PasswordData mailPassword = this.pwmApplication.getConfig().readSettingAsPassword( PwmSetting.EMAIL_PASSWORD );
-        final String mailhost = this.pwmApplication.getConfig().readSettingAsString( PwmSetting.EMAIL_SERVER_ADDRESS );
-        final int mailport = ( int ) this.pwmApplication.getConfig().readSettingAsLong( PwmSetting.EMAIL_SERVER_PORT );
+        Transport tr = null;
+        String mailHost;
+        int mailPort; String mailUser ;
+         PasswordData mailPassword ;
+
+        for ( int i = 0; i < emailServers.size(); i++) {
+            if (emailServers.get(i).isTried()) {
+                emailServers.get(i).setTried(false);
+                continue;
+            } else {
+                mailHost = emailServers.get(i).getServerAddress();
+                mailPort = emailServers.get(i).getPort();
+                mailUser = emailServers.get(i).getUsername();
+                mailPassword = emailServers.get(i).getPassword();
+                emailServers.get(i).setTried(true);
+            }
 
 
-        // Login to SMTP server first if both username and password is given
-        final javax.mail.Session session = javax.mail.Session.getInstance( javaMailProps, null );
-        final Transport tr = session.getTransport( "smtp" );
+            // Login to SMTP server first if both username and password is given
+            final javax.mail.Session session = javax.mail.Session.getInstance( javaMailProps, null );
+            tr = session.getTransport( "smtp" );
 
 
-        final boolean authenticated = !( mailUser == null || mailUser.length() < 1 || mailPassword == null );
+            final boolean authenticated = !( mailUser == null || mailUser.length() < 1 || mailPassword == null );
 
 
-        if ( authenticated )
-        {
-            // create a new Session object for the message
-            tr.connect( mailhost, mailport, mailUser, mailPassword.getStringValue() );
-        }
-        else
-        {
+        if (authenticated)
+        {    // create a new Session object for the message
+            tr.connect(mailHost, mailPort, mailUser, mailPassword.getStringValue());
+        } else {
             tr.connect();
             tr.connect();
         }
         }
 
 
-        LOGGER.debug( "connected to " + mailhost + ":" + mailport + " " + ( authenticated ? "(secure)" : "(plaintext)" ) );
+            LOGGER.debug( "connected to " + mailHost + ":" + mailPort + " " + ( authenticated ? "(secure)" : "(plaintext)" ) );
+            emailServers.get(i).setTried(false);
+            break;
+        }
         return tr;
         return tr;
     }
     }
 
 
@@ -502,11 +576,15 @@ public class EmailQueueManager implements PwmService
         //Create a properties item to start setting up the mail
         //Create a properties item to start setting up the mail
         final Properties props = new Properties();
         final Properties props = new Properties();
 
 
+        for (int i = 0; i < staticEmailServers.size(); i++) {
+            props.put("mail.smtp.host", staticEmailServers.get(i).getServerAddress());
+            props.put("mail.smtp.port",staticEmailServers.get(i).getPort());
+        }
         //Specify the desired SMTP server
         //Specify the desired SMTP server
-        props.put( "mail.smtp.host", config.readSettingAsString( PwmSetting.EMAIL_SERVER_ADDRESS ) );
+        //props.put( "mail.smtp.host", config.readSettingAsString( PwmSetting.EMAIL_SERVER_ADDRESS ) );
 
 
         //Specify SMTP server port
         //Specify SMTP server port
-        props.put( "mail.smtp.port", ( int ) config.readSettingAsLong( PwmSetting.EMAIL_SERVER_PORT ) );
+        //props.put( "mail.smtp.port", ( int ) config.readSettingAsLong( PwmSetting.EMAIL_SERVER_PORT ) );
 
 
         //Specify configured advanced settings.
         //Specify configured advanced settings.
         final Map<String, String> advancedSettingValues = StringUtil.convertStringListToNameValuePair( config.readSettingAsStringArray( PwmSetting.EMAIL_ADVANCED_SETTINGS ), "=" );
         final Map<String, String> advancedSettingValues = StringUtil.convertStringListToNameValuePair( config.readSettingAsStringArray( PwmSetting.EMAIL_ADVANCED_SETTINGS ), "=" );

+ 3 - 3
server/src/main/resources/password/pwm/i18n/PwmSetting.properties

@@ -48,8 +48,8 @@ Category_Description_EDIR_SETTINGS=NetIQ eDirectory specific settings.
 Category_Description_EMAIL=<p>Configuration settings for all sent emails.   The settings for the email body configuration are for both plaintext and HTML.  We encourage that for each configured setting and locale for the email body, that you configure both plaintext and HTML. @PwmAppName@ delivers the email in both formats and the email client can choose which to display.</p> <p>Email definitions might use macros.  For more information about macros, see the "View" menu "Show Macro Help".</p>
 Category_Description_EMAIL=<p>Configuration settings for all sent emails.   The settings for the email body configuration are for both plaintext and HTML.  We encourage that for each configured setting and locale for the email body, that you configure both plaintext and HTML. @PwmAppName@ delivers the email in both formats and the email client can choose which to display.</p> <p>Email definitions might use macros.  For more information about macros, see the "View" menu "Show Macro Help".</p>
 Category_Description_EMAIL_SETTINGS=
 Category_Description_EMAIL_SETTINGS=
 Category_Description_EMAIL_TEMPLATES=
 Category_Description_EMAIL_TEMPLATES=
-Category_Description_EMAIL_PROFILES=Multiple Email Settings
-#Categoty_Description_EMAIL_SETTING=Email settings
+Category_Description_EMAIL_PROFILES=Email Profile Settings
+Categoty_Description_EMAIL_SETTING=Email settings
 Category_Description_FORGOTTEN_USERNAME=Allows a user to search for a forgotten user name using a configurable search filter and attributes.
 Category_Description_FORGOTTEN_USERNAME=Allows a user to search for a forgotten user name using a configurable search filter and attributes.
 Category_Description_GENERAL=General settings for the application.  Settings here control the functionality and behavior of the system overall.
 Category_Description_GENERAL=General settings for the application.  Settings here control the functionality and behavior of the system overall.
 Category_Description_GUEST=Note\: The guest user registration module requires that the logged in user has sufficient permissions to create users and if so configured, to check for duplicate values.
 Category_Description_GUEST=Note\: The guest user registration module requires that the logged in user has sufficient permissions to create users and if so configured, to check for duplicate values.
@@ -147,7 +147,7 @@ Category_Label_EDIR_SETTINGS=eDirectory Settings
 Category_Label_EMAIL=Email
 Category_Label_EMAIL=Email
 Category_Label_EMAIL_SETTINGS=Email Settings
 Category_Label_EMAIL_SETTINGS=Email Settings
 Category_Label_EMAIL_TEMPLATES=Email Templates
 Category_Label_EMAIL_TEMPLATES=Email Templates
-Category_Label_EMAIL_PROFILES=Multiple Email Server Settings
+Category_Label_EMAIL_PROFILES=Email Profile Settings
 #Category_Label_EMAIL_SETTING=Email Settings
 #Category_Label_EMAIL_SETTING=Email Settings
 Category_Label_FORGOTTEN_USERNAME=Forgotten User Name
 Category_Label_FORGOTTEN_USERNAME=Forgotten User Name
 Category_Label_GENERAL=Application
 Category_Label_GENERAL=Application