|
60 | 60 | */
|
61 | 61 | public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
|
62 | 62 |
|
| 63 | + public static final String MAIL_SMTP_HOST_PK = "mail.smtp.host"; |
| 64 | + public static final String MAIL_SMTP_PORT_PK = "mail.smtp.port"; |
| 65 | + public static final String MAIL_SMTP_LOCALHOST_PK = "mail.smtp.localhost"; |
| 66 | + public static final String MAIL_SMTP_AUTH_PK = "mail.smtp.auth"; |
| 67 | + public static final String MAIL_SMTP_STARTTLS_ENABLE_PK = "mail.smtp.starttls.enable"; |
| 68 | + public static final String MAIL_TRANSPORT_PROTOCOL_PK = "mail.transport.protocol"; |
| 69 | + public static final String MAIL_SMTP_SSL_ENABLE_PK = "mail.smtp.ssl.enable"; |
63 | 70 | static InternetAddress[] EMPTY_IA_ARRAY = new InternetAddress[0];
|
64 | 71 | // ~ 14 days
|
65 | 72 | static final long MAX_DELAY_BETWEEN_STATUS_MESSAGES = 1228800 * CoreConstants.MILLIS_IN_ONE_SECOND;
|
@@ -146,31 +153,32 @@ private Session lookupSessionInJNDI() {
|
146 | 153 | private Session buildSessionFromProperties() {
|
147 | 154 | Properties props = new Properties(OptionHelper.getSystemProperties());
|
148 | 155 | if (smtpHost != null) {
|
149 |
| - props.put("mail.smtp.host", smtpHost); |
| 156 | + props.put(MAIL_SMTP_HOST_PK, smtpHost); |
150 | 157 | }
|
151 |
| - props.put("mail.smtp.port", Integer.toString(smtpPort)); |
| 158 | + |
| 159 | + props.put(MAIL_SMTP_PORT_PK, Integer.toString(smtpPort)); |
152 | 160 |
|
153 | 161 | if (localhost != null) {
|
154 |
| - props.put("mail.smtp.localhost", localhost); |
| 162 | + props.put(MAIL_SMTP_LOCALHOST_PK, localhost); |
155 | 163 | }
|
156 | 164 |
|
157 | 165 | LoginAuthenticator loginAuthenticator = null;
|
158 | 166 |
|
159 | 167 | if (!OptionHelper.isNullOrEmptyOrAllSpaces(username)) {
|
160 | 168 | loginAuthenticator = new LoginAuthenticator(username, password);
|
161 |
| - props.put("mail.smtp.auth", "true"); |
| 169 | + props.put(MAIL_SMTP_AUTH_PK, "true"); |
162 | 170 | }
|
163 | 171 |
|
164 | 172 | if (isSTARTTLS() && isSSL()) {
|
165 | 173 | addError("Both SSL and StartTLS cannot be enabled simultaneously");
|
166 | 174 | } else {
|
167 | 175 | if (isSTARTTLS()) {
|
168 | 176 | // see also http://jira.qos.ch/browse/LOGBACK-193
|
169 |
| - props.put("mail.smtp.starttls.enable", "true"); |
170 |
| - props.put("mail.transport.protocol", "true"); |
| 177 | + props.put(MAIL_SMTP_STARTTLS_ENABLE_PK, "true"); |
| 178 | + props.put(MAIL_TRANSPORT_PROTOCOL_PK, "true"); |
171 | 179 | }
|
172 | 180 | if (isSSL()) {
|
173 |
| - props.put("mail.smtp.ssl.enable", "true"); |
| 181 | + props.put(MAIL_SMTP_SSL_ENABLE_PK, "true"); |
174 | 182 | }
|
175 | 183 | }
|
176 | 184 |
|
|
0 commit comments