Javamail properties

JavaMail provides a set of properties that can be used to configure the behavior of the JavaMail API. These properties can be set using the Session object, which is used to create a JavaMail session.

Here are some common JavaMail properties:

  1. mail.store.protocol: specifies the protocol to use for storing messages (e.g. POP3, IMAP, etc.)
  2. mail.store.host: specifies the hostname of the mail server for storing messages
  3. mail.store.port: specifies the port number to use for storing messages
  4. mail.transport.protocol: specifies the protocol to use for sending messages (e.g. SMTP, etc.)
  5. mail.transport.host: specifies the hostname of the mail server for sending messages
  6. mail.transport.port: specifies the port number to use for sending messages
  7. mail.debug: specifies whether to enable debug output (true or false)
  8. mail.debug.auth: specifies whether to enable debug output for authentication (true or false)
  9. mail.debug.msgs: specifies whether to enable debug output for messages (true or false)
  10. mail.debug.init: specifies whether to enable debug output for initialization (true or false)
  11. mail.debug.stack: specifies whether to enable debug output for stack traces (true or false)
  12. mail.mime.charset: specifies the character set to use for decoding MIME messages
  13. mail.mime.decodefile: specifies whether to decode file attachments (true or false)
  14. mail.mime.decodeparameters: specifies whether to decode MIME parameters (true or false)
  15. mail.mime.encodefile: specifies whether to encode file attachments (true or false)
  16. mail.mime.encodeparameters: specifies whether to encode MIME parameters (true or false)
  17. mail.smtp.auth: specifies whether to use authentication for SMTP (true or false)
  18. mail.smtp.starttls.enable: specifies whether to use STARTTLS for SMTP (true or false)
  19. mail.smtp.starttls.required: specifies whether to require STARTTLS for SMTP (true or false)
  20. mail.imap.auth: specifies whether to use authentication for IMAP (true or false)
  21. mail.imap.starttls.enable: specifies whether to use STARTTLS for IMAP (true or false)
  22. mail.imap.starttls.required: specifies whether to require STARTTLS for IMAP (true or false)

Here is an example of how to set these properties using the Session object:

Properties props = new Properties();
props.put("mail.store.protocol", "pop3");
props.put("mail.store.host", "pop3.example.com");
props.put("mail.store.port", "110");
props.put("mail.transport.protocol", "smtp");
props.put("mail.transport.host", "smtp.example.com");
props.put("mail.transport.port", "25");
props.put("mail.debug", "true");

Session session = Session.getInstance(props, null);

Note that the Session object can also be used to set properties for a specific connection, by calling the setProperties() method on the Store or Transport object.