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.mail2.core; 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="https://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-summary.html"> 026 * https://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 /** Charset constant for koi8-r */ 033 public static final String KOI8_R = "koi8-r"; 034 035 /** Charset constant for iso-8859-1 */ 036 public static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name(); 037 038 /** Charset constant for us-ascii */ 039 public static final String US_ASCII = StandardCharsets.US_ASCII.name(); 040 041 /** Charset constant for utf-8 */ 042 public static final String UTF_8 = StandardCharsets.UTF_8.name(); 043 044 /** The debug mode to be used. */ 045 public static final String MAIL_DEBUG = "mail.debug"; 046 047 /** The host name of the mail server. */ 048 public static final String MAIL_HOST = "mail.smtp.host"; 049 050 /** The port number of the mail server. */ 051 public static final String MAIL_PORT = "mail.smtp.port"; 052 053 /** The email address to use for SMTP MAIL command. */ 054 public static final String MAIL_SMTP_FROM = "mail.smtp.from"; 055 056 /** If set to true, tries to authenticate the user using the AUTH command. */ 057 public static final String MAIL_SMTP_AUTH = "mail.smtp.auth"; 058 059 /** The SMTP user name. */ 060 public static final String MAIL_SMTP_USER = "mail.smtp.user"; 061 062 /** The SMTP password. */ 063 public static final String MAIL_SMTP_PASSWORD = "mail.smtp.password"; 064 065 /** Specifies the default transport protocol */ 066 public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol"; 067 068 /** The value to use SMTP as transport protocol */ 069 public static final String SMTP = "smtp"; 070 071 /** Defines the text/html content type */ 072 public static final String TEXT_HTML = "text/html"; 073 074 /** Defines the html subtype */ 075 public static final String TEXT_SUBTYPE_HTML = "html"; 076 077 /** Defines the text/plain content type */ 078 public static final String TEXT_PLAIN = "text/plain"; 079 080 ///////////////////////////////////////////////////////////////////////// 081 // since 1.1 082 ///////////////////////////////////////////////////////////////////////// 083 084 /** 085 * Indicates if the STARTTLS command shall be used to initiate a TLS-secured connection. 086 * 087 * @since 1.1 088 */ 089 public static final String MAIL_TRANSPORT_STARTTLS_ENABLE = "mail.smtp.starttls.enable"; 090 091 /** 092 * Whether to use {@link java.net.Socket} as a fallback if the initial connection fails or not. 093 * 094 * @since 1.1 095 */ 096 public static final String MAIL_SMTP_SOCKET_FACTORY_FALLBACK = "mail.smtp.socketFactory.fallback"; 097 098 /** 099 * Specifies the {@link javax.net.SocketFactory} class to create smtp sockets. 100 * 101 * @since 1.1 102 */ 103 public static final String MAIL_SMTP_SOCKET_FACTORY_CLASS = "mail.smtp.socketFactory.class"; 104 105 /** 106 * Specifies the port to connect to when using a socket factory. 107 * 108 * @since 1.1 109 */ 110 public static final String MAIL_SMTP_SOCKET_FACTORY_PORT = "mail.smtp.socketFactory.port"; 111 112 /** 113 * Socket connection timeout value in milliseconds. Default is infinite timeout. 114 * 115 * @since 1.2 116 */ 117 public static final String MAIL_SMTP_CONNECTIONTIMEOUT = "mail.smtp.connectiontimeout"; 118 119 /** 120 * Socket I/O timeout value in milliseconds. Default is infinite timeout. 121 * 122 * @since 1.2 123 */ 124 public static final String MAIL_SMTP_TIMEOUT = "mail.smtp.timeout"; 125 126 /** 127 * Default socket timeout. 128 * 129 * @since 1.6.0 130 */ 131 public static final Duration SOCKET_TIMEOUT = Duration.ofMinutes(1); 132 133 /** 134 * If true, requires the use of the STARTTLS command. If the server doesn't support the STARTTLS command, the connection will fail. 135 * 136 * @since 1.3 137 */ 138 public static final String MAIL_TRANSPORT_STARTTLS_REQUIRED = "mail.smtp.starttls.required"; 139 140 /** 141 * If set to true, use SSL to connect and use the SSL port by default. 142 * 143 * @since 1.3 144 */ 145 public static final String MAIL_SMTP_SSL_ENABLE = "mail.smtp.ssl.enable"; 146 147 /** 148 * If set to true, check the server identity as specified in RFC 2595. 149 * 150 * @since 1.3 151 */ 152 public static final String MAIL_SMTP_SSL_CHECKSERVERIDENTITY = "mail.smtp.ssl.checkserveridentity"; 153 154 /** 155 * Specifies the {@link javax.net.ssl.SSLSocketFactory} class to use to create SMTP SSL sockets. 156 * 157 * @since 1.3 158 */ 159 public static final String MAIL_SMTP_SSL_SOCKET_FACTORY_CLASS = "mail.smtp.ssl.socketFactory.class"; 160 161 /** 162 * Specifies the port to connect to when using the SMTP SSL socket factory. 163 * 164 * @since 1.3 165 */ 166 public static final String MAIL_SMTP_SSL_SOCKET_FACTORY_PORT = "mail.smtp.ssl.socketFactory.port"; 167 168 ///////////////////////////////////////////////////////////////////////// 169 // since 1.3.2 170 ///////////////////////////////////////////////////////////////////////// 171 172 /** 173 * If set to true, and a message has some valid and some invalid addresses, send the message anyway, reporting the partial failure with a 174 * SendFailedException. If set to false (the default), the message is not sent to any of the recipients if there is an invalid recipient address. 175 * 176 * @since 1.3.2 177 */ 178 public static final String MAIL_SMTP_SEND_PARTIAL = "mail.smtp.sendpartial"; 179 180 /** 181 * If set to true, and a message has some valid and some invalid addresses, send the message anyway, reporting the partial failure with a 182 * SendFailedException. If set to false (the default), the message is not sent to any of the recipients if there is an invalid recipient address. 183 * 184 * @since 1.3.2 185 */ 186 public static final String MAIL_SMTPS_SEND_PARTIAL = "mail.smtps.sendpartial"; 187 188 /** 189 * Defines the default mime charset to use when none has been specified for the message. 190 * 191 * @since 1.3.2 192 */ 193 public static final String MAIL_MIME_CHARSET = "mail.mime.charset"; 194 195 ///////////////////////////////////////////////////////////////////////// 196 // since 1.4 197 ///////////////////////////////////////////////////////////////////////// 198 199 /** 200 * The from email address. 201 * 202 * @since 1.4 203 */ 204 public static final String MAIL_FROM = "mail.from"; 205 206 /** Hide constructor. */ 207 private EmailConstants() { 208 // do nothing 209 } 210 211}