Updated April 15, 2023
Introduction to Java Mail Properties
JavaMail Properties are used to set in the session objects and to create the session object. Their properties are mostly set as a string and the type depicts how the string actually interpreted. The JavaMail properties include the javax.mail packages and sub package properties. In JavaMail properties are mentioned in javax.mail execution under J2EE implementation that properties are set as a string and their types describe how those strings are interpreted. In this topic, we are going to learn about Java Mail Properties.
What is JavaMail Properties?
The JavaMail is used to compose, read and write E-mails, the JavaMail API is a framework that is used to build a mail and message for the client application by platform and protocol independent. JavaMail is generally used for sending and reading E-mails and it requires the service providers to cooperate with mail servers to execute the transport protocols. The javax.mail.internet package determines the class related to the mailing system based on internet standards like POP3, IMAP, SMTP and MIME it includes the package and sub-packages of javax.mail.
List of Java Mail Properties
JavaMail API supports the standard properties in which the Properties object is used to create the session object and it set in the Session object. Those properties are mostly set as a string and their type column defines how the string is interpreted. Let’s see the following properties,
IMAP (Internet Message Access Protocol)
This IMAP protocol maintains the following properties they are set in the JavaMail Session object, when using the imaps protocol for accessing IMAP over SSL most of the properties will be named as “mail.imaps.*”.
NAME | TYPE | DESCRIPTION |
mail.imap.user | String | It is the default name of the user for IMAP |
mail.imap.host | String | It is the IMAP server for Connection – connect to |
mail.imap.port | Int | It is the IMAP server port for connection. It defaults to 143 if the connect() method doesn’t not sets to 1. |
mail. imap. fetchsize | Int | The default size is 16K. Partial fetch size records in bytes. |
mail. imap. peek | Boolean | It defaults to false. If it is set to true use IMAP PEEK option for fetching body parts, to avoid the SEEN flag on messages. |
mail. imap. connectiontimeout | int | Default is infinite timeout. The Socket connection timeout value in milliseconds. It is implemented by java. net. Socket. |
mail. imap. timeout | int | Default is infinite timeout. The Socket read timeout value in milliseconds. It is implemented by java. net. Socket. |
mail. Imap. Writetimeout | int | Default is infinite timeout. The Socket writes timeout value in milliseconds. The timeout is implemented by java. util. Concurrent. SchedulrExecutorService per connection. |
mail. imap. statuscachetimeout | int | The timeout value in milliseconds from cache of STATUS command response. The default value is 1000(1 second), here cache disables zero. |
mail. imap. Connectionpoolsize | int | The default value is 1. There will be a maximum number of available connections in the connection pool. |
JavaMail Properties Controlled – IMAP (Internet Message Access Protocol)
Additionally to print for debugging output will be controlled by Session Configuration, there will be a provider logs in com.sun.mail.imap contains the same information using Logger explained in the table as follows,
Logger Name | Logging Level | Purpose |
com.sun.mail.imap | CONFIG | it is the Configuration of IMAPStore |
com.sun.mail.imap | FINE | It is the General debugging output |
com.sun.mail.imap. connectionpool | CONFIG | It is the Configuration of the IMAP connection pool |
com.sun.mail.imap . connectionpool | FINE | It is the Debugging output related to the IMAP connection pool |
com.sun.mail.imap. messagecache | CONFIG | It is the configuration of IMAP message cache |
com.sun.mail.imap. messagecache | FINE | It is related to the debugging output which is related to IMAP message cache |
com.sun.mail.imap. protocol | FINEST | To complete the protocol trace. |
SMPT (Simple Mail Transfer Protocol)
This SMTP protocol maintains the following properties they are set in the JavaMail Session object, when using the “smtps” protocol for accessing SMTP over SSL most of the properties will be named as “mail.smtps.*”.
NAME | TYPE | DESCRIPTION |
mail. smtp. user | String | The default name of the user is SMPT |
mail. smtp. host | string | This is SMPT server to connect to. |
mail. smtp. port | int | It is the SMTP server port for connection. It defaults to 25, if the connect() method doesn’t explicitly set one. |
mail. smtp. connectiontimeout | int | Default is infinite timeout. The Socket connection timeout value is in milliseconds. It is implemented by java. net. Socket. |
mail. smtp. timeout | int | Default is infinite timeout. The Socket read timeout value in milliseconds. It is implemented by java. net. Socket. |
mail. smtp. Writetimeout | int | Default is infinite timeout. The Socket writes timeout value in milliseconds. The timeout is implemented by java. util. Concurrent. SchedulrExecutorService per connection. |
mail. smtp. auth | Boolean | Its defaults are set to false, it sets to true it attempts to authenticate the user by AUTH command |
mail. smtp. ssl. Enable | boolean | By default, it sets to false for “smtp” and sets true for “smtps” protocol, if we setting true use the SSL connection and use the SSL port default. |
mail. smtp. proxy. host | string | To specify hostname the HTTP web proxy server be used for connecting mail-server. |
mail. smtp. proxy. Port | string | The default port is 80. To specify port number for HTTP web proxy server. |
JavaMail Properties Controlled – SMPT (Simple Mail Transfer Protocol)
Additionally to print for debugging output will be controlled by Session Configuration, there will be a provider logs in com.sun.mail.smtp contains the same information using Logger explained in the table as follows,
Logger Name | Logging Level | Purpose |
com.sun.mail.smtp | CONFIG | it is the Configuration of SMTPTransport |
com.sun.mail.smtp | FINE | It is the General debugging output |
com.sun.mail.smtp. protocol | FINEST | To complete the protocol trace. |
POP3 (Post Office Protocol)
POP3 protocol provides the JavaMail API which allows access to the POP3 message store. This POP3 protocol maintains a store object which contains a particular Folder named “INBOX”.
Their URL format will be in the form of “pop3://user:password@host:port/INBOX”. The following properties they are set in the JavaMail Session object, when using the “pop3s” protocol for accessing POP3 over SSL most of the properties will be named as “mail.pop3s.*”.
NAME | TYPE | DESCRIPTION |
mail. pop3. user | String | The default name of user is POP3 |
mail. pop3. host | string | This is POP3 server to connect to. |
mail. pop3. port | int | It is the POP3 server port for connection. It defaults to 110, if the connect () method doesn’t not explicitly sets one. |
mail. pop3. connectiontimeout | int | Default is infinite timeout. The Socket connection timeout value in milliseconds. It is implemented by java. net. Socket. |
mail. pop3. timeout | int | Default is infinite timeout. The Socket read timeout value in milliseconds. It is implemented by java. net. Socket. |
mail. smtp. Writetimeout | int | Default is infinite timeout. The Socket write timeout value in milliseconds. The timeout is implemented by java. util. Concurrent. SchedulrExecutorService per connection. |
JavaMail Properties Controlled – POP3 (Post Office Protocol)
Additionally to print for debugging output will be controlled by Session Configuration, there will be a provider logs in com.sun.mail.pop3 contains the same information using Logger explained in the table as follows,
Logger Name | Logging Level | Purpose |
com.sun.mail.pop3 | CONFIG | it is the Configuration of POP3Store |
com.sun.mail.pop3 | FINE | It is the General debugging output |
com.sun.mail.pop3. protocol | FINEST | To complete the protocol trace. |
Conclusion
In this article I have explained about the Properties of JavaMail. By using the JavaMail Properties it is easy to set in the session objects and to create the session object. Hope the article helps you use the properties of JavaMail.
Recommended Articles
This is a guide to Java Mail Properties. Here we discuss the Properties of JavaMail. By using the JavaMail Properties it is easy to set in the session objects. You may also have a look at the following articles to learn more –