001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.mail; 018 019import java.nio.charset.StandardCharsets; 020import java.time.Duration; 021 022/** 023 * Constants used by Email classes. 024 * 025 * A description of the mail session parameter you find at <a href="http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html"> 026 * http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html</a>. 027 * 028 * @since 1.3 029 */ 030public final class EmailConstants { 031 032 /** @deprecated since 1.3, not in use since 1.0 */ 033 @Deprecated 034 public static final String SENDER_EMAIL = "sender.email"; 035 036 /** @deprecated since 1.3, not in use since 1.0 */ 037 @Deprecated 038 public static final String SENDER_NAME = "sender.name"; 039 040 /** @deprecated since 1.3, not in use since 1.0 */ 041 @Deprecated 042 public static final String RECEIVER_EMAIL = "receiver.email"; 043 044 /** @deprecated since 1.3, not in use since 1.0 */ 045 @Deprecated 046 public static final String RECEIVER_NAME = "receiver.name"; 047 048 /** @deprecated since 1.3, not in use since 1.0 */ 049 @Deprecated 050 public static final String EMAIL_SUBJECT = "email.subject"; 051 052 /** @deprecated since 1.3, not in use since 1.0 */ 053 @Deprecated 054 public static final String EMAIL_BODY = "email.body"; 055 056 /** @deprecated since 1.3, not in use since 1.0 */ 057 @Deprecated 058 public static final String CONTENT_TYPE = "content.type"; 059 060 /** @deprecated since 1.3, not in use since 1.0 */ 061 @Deprecated 062 public static final String ATTACHMENTS = "attachments"; 063 064 /** @deprecated since 1.3, not in use since 1.0 */ 065 @Deprecated 066 public static final String FILE_SERVER = "file.server"; 067 068 // Charset constants 069 070 /** Charset constant for koi8-r */ 071 public static final String KOI8_R = "koi8-r"; 072 073 /** Charset constant for iso-8859-1 */ 074 public static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name(); 075 076 /** Charset constant for us-ascii */ 077 public static final String US_ASCII = StandardCharsets.US_ASCII.name(); 078 079 /** Charset constant for utf-8 */ 080 public static final String UTF_8 = StandardCharsets.UTF_8.name(); 081 082 /** The debug mode to be used. */ 083 public static final String MAIL_DEBUG = "mail.debug"; 084 085 /** The host name of the mail server. */ 086 public static final String MAIL_HOST = "mail.smtp.host"; 087 088 /** The port number of the mail server. */ 089 public static final String MAIL_PORT = "mail.smtp.port"; 090 091 /** The email address to use for SMTP MAIL command. */ 092 public static final String MAIL_SMTP_FROM = "mail.smtp.from"; 093 094 /** If set to true, tries to authenticate the user using the AUTH command. */ 095 public static final String MAIL_SMTP_AUTH = "mail.smtp.auth"; 096 097 /** The SMTP user name. */ 098 public static final String MAIL_SMTP_USER = "mail.smtp.user"; 099 100 /** The SMTP password. */ 101 public static final String MAIL_SMTP_PASSWORD = "mail.smtp.password"; 102 103 /** Specifies the default transport protocol */ 104 public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol"; 105 106 /** The value to use SMTP as transport protocol */ 107 public static final String SMTP = "smtp"; 108 109 /** Defines the text/html content type */ 110 public static final String TEXT_HTML = "text/html"; 111 112 /** Defines the html subtype */ 113 public static final String TEXT_SUBTYPE_HTML = "html"; 114 115 /** Defines the text/plain content type */ 116 public static final String TEXT_PLAIN = "text/plain"; 117 118 ///////////////////////////////////////////////////////////////////////// 119 // since 1.1 120 ///////////////////////////////////////////////////////////////////////// 121 122 /** @deprecated since 1.3 */ 123 @Deprecated 124 public static final String MAIL_TRANSPORT_TLS = "mail.smtp.starttls.enable"; 125 126 /** 127 * Indicates if the STARTTLS command shall be used to initiate a TLS-secured connection. 128 * 129 * @since 1.1 130 */ 131 public static final String MAIL_TRANSPORT_STARTTLS_ENABLE = "mail.smtp.starttls.enable"; 132 133 /** 134 * Whether to use {@link java.net.Socket} as a fallback if the initial connection fails or not. 135 * 136 * @since 1.1 137 */ 138 public static final String MAIL_SMTP_SOCKET_FACTORY_FALLBACK = "mail.smtp.socketFactory.fallback"; 139 140 /** 141 * Specifies the {@link javax.net.SocketFactory} class to create smtp sockets. 142 * 143 * @since 1.1 144 */ 145 public static final String MAIL_SMTP_SOCKET_FACTORY_CLASS = "mail.smtp.socketFactory.class"; 146 147 /** 148 * Specifies the port to connect to when using a socket factory. 149 * 150 * @since 1.1 151 */ 152 public static final String MAIL_SMTP_SOCKET_FACTORY_PORT = "mail.smtp.socketFactory.port"; 153 154 /** 155 * Socket connection timeout value in milliseconds. Default is infinite timeout. 156 * 157 * @since 1.2 158 */ 159 public static final String MAIL_SMTP_CONNECTIONTIMEOUT = "mail.smtp.connectiontimeout"; 160 161 /** 162 * Socket I/O timeout value in milliseconds. Default is infinite timeout. 163 * 164 * @since 1.2 165 */ 166 public static final String MAIL_SMTP_TIMEOUT = "mail.smtp.timeout"; 167 168 /** 169 * Default socket timeout. 170 * 171 * @since 1.6.0 172 */ 173 public static final Duration SOCKET_TIMEOUT = Duration.ofMinutes(1); 174 175 /** 176 * Default socket timeout. 177 * 178 * @since 1.3 179 * @deprecated Use {@link #SOCKET_TIMEOUT}. 180 */ 181 @Deprecated 182 public static final int SOCKET_TIMEOUT_MS = 60_000; 183 184 /** 185 * If true, requires the use of the STARTTLS command. If the server doesn't support the STARTTLS command, the connection will fail. 186 * 187 * @since 1.3 188 */ 189 public static final String MAIL_TRANSPORT_STARTTLS_REQUIRED = "mail.smtp.starttls.required"; 190 191 /** 192 * If set to true, use SSL to connect and use the SSL port by default. 193 * 194 * @since 1.3 195 */ 196 public static final String MAIL_SMTP_SSL_ENABLE = "mail.smtp.ssl.enable"; 197 198 /** 199 * If set to true, check the server identity as specified in RFC 2595. 200 * 201 * @since 1.3 202 */ 203 public static final String MAIL_SMTP_SSL_CHECKSERVERIDENTITY = "mail.smtp.ssl.checkserveridentity"; 204 205 /** 206 * Specifies the {@link javax.net.ssl.SSLSocketFactory} class to use to create SMTP SSL sockets. 207 * 208 * @since 1.3 209 */ 210 public static final String MAIL_SMTP_SSL_SOCKET_FACTORY_CLASS = "mail.smtp.ssl.socketFactory.class"; 211 212 /** 213 * Specifies the port to connect to when using the SMTP SSL socket factory. 214 * 215 * @since 1.3 216 */ 217 public static final String MAIL_SMTP_SSL_SOCKET_FACTORY_PORT = "mail.smtp.ssl.socketFactory.port"; 218 219 ///////////////////////////////////////////////////////////////////////// 220 // since 1.3.2 221 ///////////////////////////////////////////////////////////////////////// 222 223 /** 224 * If set to true, and a message has some valid and some invalid addresses, send the message anyway, reporting the partial failure with a 225 * SendFailedException. If set to false (the default), the message is not sent to any of the recipients if there is an invalid recipient address. 226 * 227 * @since 1.3.2 228 */ 229 public static final String MAIL_SMTP_SEND_PARTIAL = "mail.smtp.sendpartial"; 230 231 /** 232 * If set to true, and a message has some valid and some invalid addresses, send the message anyway, reporting the partial failure with a 233 * SendFailedException. If set to false (the default), the message is not sent to any of the recipients if there is an invalid recipient address. 234 * 235 * @since 1.3.2 236 */ 237 public static final String MAIL_SMTPS_SEND_PARTIAL = "mail.smtps.sendpartial"; 238 239 /** 240 * Defines the default mime charset to use when none has been specified for the message. 241 * 242 * @since 1.3.2 243 */ 244 public static final String MAIL_MIME_CHARSET = "mail.mime.charset"; 245 246 ///////////////////////////////////////////////////////////////////////// 247 // since 1.4 248 ///////////////////////////////////////////////////////////////////////// 249 250 /** 251 * The from email address. 252 * 253 * @since 1.4 254 */ 255 public static final String MAIL_FROM = "mail.from"; 256 257 /** Hide constructor. */ 258 private EmailConstants() { 259 // do nothing 260 } 261 262}