### Example: Initialize ImapConnection Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/AbstractConnection.md This example demonstrates how to initialize an ImapConnection using the default AbstractConnection constructor and start its protocol handling. ```java Socket clientSocket = serverSocket.accept(); ImapConnection conn = new ImapConnection(clientSocket); conn.start(); // Begin protocol handling ``` -------------------------------- ### start() Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/DavGateway.md Starts all configured DavMail protocol servers (SMTP, POP3, IMAP, CalDAV, LDAP) based on the current `Settings` configuration. It binds server sockets and starts each server in a separate thread. ```APIDOC ## start() ### Description Start all configured DavMail protocol servers based on `Settings` configuration. Creates and binds server instances for: SMTP, POP3, IMAP, CalDAV, LDAP. ### Method `public static void start()` ### Parameters None ### Return void ### Behavior - Clears any existing server list - Reads port configuration from `Settings` properties - Binds each server socket - Starts each server thread - Checks for new releases in background - Displays startup banner with listening ports - Reports any binding errors but continues startup ### Throws None (handles exceptions internally, logs errors) ### Example ```java // Configure settings and start servers Settings.setProperty("davmail.smtpPort", "1025"); Settings.setProperty("davmail.imapPort", "1143"); DavGateway.start(); ``` ``` -------------------------------- ### Starting the DavMail Application Source: https://github.com/mguessan/davmail/blob/master/_autodocs/SUMMARY.txt Illustrates the basic command to start the DavMail application. This is a common entry point for users. ```bash java -jar davmail.jar ``` -------------------------------- ### Check for First DavMail Start Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Determines if the application is being launched for the first time, indicated by the absence of a configuration file. This can be used to trigger initial setup wizards or welcome dialogs. ```java public static synchronized boolean isFirstStart() ``` ```java if (Settings.isFirstStart()) { // Show welcome dialog showWelcomeDialog(); } ``` -------------------------------- ### Start DavMail Gateway Source: https://github.com/mguessan/davmail/blob/master/_autodocs/INDEX.md Load settings and start the DavMail gateway. Ensure the configuration file path is set correctly. ```java Settings.setConfigFilePath("/etc/davmail/davmail.properties"); Settings.load(); DavGateway.start(); DavGateway.stop(); ``` -------------------------------- ### load() Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Loads all settings from the configured properties file. If the file does not exist, it creates a default file with example settings. ```APIDOC ## load() ### Description Load all settings from the configured properties file. Creates default file with example settings if it doesn't exist. ### Method `public static synchronized void load()` ### Behavior - Reads from file path set by `setConfigFilePath()` - Creates file if it doesn't exist - Merges with built-in defaults - Updates logging configuration - Detects first start (new installation) ### Response #### Success Response - None (logs errors internally) ### Request Example ```java Settings.load(); String url = Settings.getProperty("davmail.url"); ``` ``` -------------------------------- ### IMAP FETCH Command Example Source: https://github.com/mguessan/davmail/blob/master/_autodocs/ARCHITECTURE.md Illustrates the step-by-step process for handling an IMAP FETCH command, from client request to server response. ```text 1. Client sends: A001 FETCH 1 BODY 2. ImapConnection.handleCommand("FETCH", ...) 3. Parse: messageId=1, format=BODY 4. ExchangeSession.getMessage(messageId) 5. Convert Message to MIME format 6. Send IMAP response: * 1 FETCH (BODY ...) ``` -------------------------------- ### Server Creation Pattern Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/ProtocolServers.md Demonstrates the common pattern for creating, binding, starting, and stopping server instances like SmtpServer. ```java // Create server on default port SmtpServer smtpServer = new SmtpServer(0); // Or specific port SmtpServer customPortServer = new SmtpServer(2025); // Bind to port smtpServer.bind(); // Start accepting connections smtpServer.start(); // Later, stop the server smtpServer.close(); ``` -------------------------------- ### Example: Initialize CaldavConnection with UTF-8 Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/AbstractConnection.md This example shows how to create a CaldavConnection instance, specifying UTF-8 encoding for broader character support. ```java // UTF-8 supporting connection CaldavConnection conn = new CaldavConnection(socket, "UTF-8"); ``` -------------------------------- ### Socket Configuration Source: https://github.com/mguessan/davmail/blob/master/_autodocs/SUMMARY.txt Provides examples of configuring socket-related properties for network connections. ```properties # Example socket configuration properties # davmail.socket.timeout=30000 # davmail.socket.receiveBuffer=65536 ``` -------------------------------- ### Load DavMail Settings from File Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Loads all application settings from the configured properties file. If the file does not exist, it creates a default one with example settings. This method also updates logging and detects the first application start. ```java public static synchronized void load() ``` ```java Settings.load(); String url = Settings.getProperty("davmail.url"); ``` -------------------------------- ### DavMail Properties Configuration Example Source: https://github.com/mguessan/davmail/blob/master/_autodocs/configuration.md Example of a Java properties file for DavMail configuration. Ensure UTF-8 encoding for the file. ```properties davmail.url=https://outlook.office365.com davmail.mode=O365EWS davmail.authentication=O365Interactive davmail.smtpPort=1025 davmail.imapPort=1143 ``` -------------------------------- ### Start DavMail Application Programmatically Source: https://github.com/mguessan/davmail/blob/master/_autodocs/README.md Load DavMail settings from a configuration file and start the gateway servers using the DavGateway class. ```java import davmail.DavGateway; import davmail.Settings; // Configure Settings.setConfigFilePath("/etc/davmail/davmail.properties"); Settings.load(); // Start servers DavGateway.start(); // Later: stop gracefully DavGateway.stop(); ``` -------------------------------- ### Initialize and Load Settings on Application Startup Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Demonstrates how to initialize DavMail settings by setting a configuration file path and loading the settings. It also shows how to check if it's the first start. ```java // Initialize settings early Settings.setConfigFilePath(configPath); Settings.load(); // Check first start if (Settings.isFirstStart()) { showSetupDialog(); } // Access configuration String exchangeUrl = Settings.getProperty("davmail.url"); int smtpPort = Settings.getIntProperty("davmail.smtpPort"); boolean serverMode = Settings.getBooleanProperty("davmail.server"); ``` -------------------------------- ### Interactive Program Notice (GPL) Source: https://github.com/mguessan/davmail/blob/master/src/license.txt Display this short notice when your program starts in interactive mode to inform users about its free software status and warranty. ```text Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### main() Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/DavGateway.md The main entry point for the DavGateway application. It handles command-line arguments to configure and start the gateway in various modes (GUI, server, token extraction, Kerberos testing). ```APIDOC ## main() ### Description Main entry point for the application. Processes command-line arguments, loads configuration, and starts the gateway. ### Method `public static void main(String[] args)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **args** (String[]) - Required - Command-line arguments - `-notray` — disable system tray (GUI mode only) - `-tray` — enable system tray (GUI mode only) - `-server` — run in server mode (headless) - `-token` — extract OAuth refresh token and exit - `-kerberos` — test Kerberos authentication and exit - `configFilePath` — path to davmail.properties configuration file ### Behavior - If no config file path provided, uses default location from `Settings.getConfigFilePath()` - In GUI mode with tray support, initializes system tray - In server mode, blocks on shutdown hook until interrupted - Exits immediately when using `-token` or `-kerberos` flags ### Throws None (exceptions logged and handled internally) ### Example ```java // Start in server mode with custom config DavGateway.main(new String[]{"-server", "/etc/davmail/davmail.properties"}); // Start with default GUI and config DavGateway.main(new String[]{}); // Extract O365 token DavGateway.main(new String[]{"-token"}); ``` ``` -------------------------------- ### Example Usage of DavMailException Source: https://github.com/mguessan/davmail/blob/master/_autodocs/errors.md Demonstrates how to catch and handle DavMailExceptions, accessing English and localized messages, and the BundleMessage object. ```java try { ExchangeSession session = ExchangeSessionFactory.getInstance(url, user, pass); } catch (DavMailException e) { String msg = e.getMessage(); // English message String localized = e.getMessage(Locale.FRENCH); // French message BundleMessage bundleMsg = e.getBundleMessage(); System.err.println("DavMail Error: " + msg); } ``` -------------------------------- ### AbstractServer Source: https://github.com/mguessan/davmail/blob/master/_autodocs/SUMMARY.txt Reference for the AbstractServer base class, detailing server configuration and port binding, including SSL/TLS setup. ```APIDOC ## AbstractServer ### Description Base class for all server implementations in DavMail. Handles common server functionalities such as port binding and SSL/TLS configuration. ### Methods - `bind(port, ssl)`: Binds the server to a specified port and configures SSL if required. - `configureSSL(sslContext)`: Configures the SSL context for secure connections. ``` -------------------------------- ### VCardWriter Example Source: https://github.com/mguessan/davmail/blob/master/_autodocs/types.md Demonstrates how to use the `VCardWriter` to construct a vCard (contact) object programmatically. Use this builder for creating vCard data. ```java VCardWriter writer = new VCardWriter(); writer.startCard("3.0"); writer.appendProperty("N", "Doe", "John", "", "", ""); writer.appendProperty("FN", "John Doe"); writer.appendProperty("EMAIL;TYPE=INTERNET", "john@example.com"); writer.appendProperty("TEL;TYPE=VOICE", "+1-555-1234"); writer.endCard(); String vcard = writer.toString(); ``` -------------------------------- ### Standard GPL Copyright Notice Source: https://github.com/mguessan/davmail/blob/master/src/license.txt Include this notice at the start of each source file to convey the exclusion of warranty and specify distribution terms under the GNU GPL. ```text Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ``` -------------------------------- ### BundleMessage Example Usage Source: https://github.com/mguessan/davmail/blob/master/_autodocs/types.md Demonstrates how to create and use BundleMessage objects to format localized messages and log messages. Shows instantiation with a key and arguments, and formatting for French locale and log output. ```java BundleMessage msg = new BundleMessage("LOG_PROTOCOL_PORT", "IMAP", 1143); String localized = msg.format(Locale.FRENCH); // French message String log = msg.formatLog(); // English log format ``` -------------------------------- ### Creating Custom Protocol Servers Source: https://github.com/mguessan/davmail/blob/master/_autodocs/SUMMARY.txt Provides a conceptual example of how to create custom protocol servers within DavMail. This is for advanced users extending DavMail's functionality. ```java // Conceptual example for creating a custom protocol server public class CustomProtocolServer extends AbstractServer { @Override public void run() { // Implementation for the custom protocol server } } ``` -------------------------------- ### Docker Deployment Configuration Source: https://github.com/mguessan/davmail/blob/master/_autodocs/SUMMARY.txt Shows example environment variables or configuration settings relevant for deploying DavMail within a Docker container. ```env # Example environment variables for Docker deployment # -e DAVMAIL_EXCHANGE_URL=https://outlook.office365.com/EWS/Exchange.asmx # -e DAVMAIL_USERNAME=your_username # -e DAVMAIL_PASSWORD=your_password ``` -------------------------------- ### DavGateway Source: https://github.com/mguessan/davmail/blob/master/_autodocs/SUMMARY.txt Documentation for the DavGateway class, which serves as the application entry point. It covers application lifecycle management, including starting and stopping the application. ```APIDOC ## DavGateway ### Description Provides methods for managing the application lifecycle, including starting and stopping the DavMail application. ### Methods - `main()`: Entry point for the application. - `start()`: Initializes and starts the DavMail application services. - `stop()`: Shuts down the DavMail application gracefully. ``` -------------------------------- ### Configuring Exchange Connection Source: https://github.com/mguessan/davmail/blob/master/_autodocs/SUMMARY.txt Shows an example of how to configure the connection to an Exchange server using DavMail. This typically involves setting server details and credentials. ```properties # Example configuration for Exchange connection # davmail.exchange.url=https://outlook.office365.com/EWS/Exchange.asmx # davmail.username=your_username # davmail.password=your_password ``` -------------------------------- ### Start DavMail Protocol Servers Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/DavGateway.md Initiates all configured DavMail protocol servers (SMTP, POP3, IMAP, CalDAV, LDAP) based on the current Settings. Ensure ports are configured in Settings before calling. ```java Settings.setProperty("davmail.smtpPort", "1025"); Settings.setProperty("davmail.imapPort", "1143"); DavGateway.start(); ``` -------------------------------- ### Setting up SSL/TLS Source: https://github.com/mguessan/davmail/blob/master/_autodocs/SUMMARY.txt Illustrates configuration properties for setting up SSL/TLS connections, essential for secure communication. ```properties # Example properties for SSL/TLS configuration # davmail.ssl.truststore=path/to/truststore.jks # davmail.ssl.truststorePassword=password # davmail.ssl.keystore=path/to/keystore.jks # davmail.ssl.keystorePassword=password ``` -------------------------------- ### isFirstStart() Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Checks if this is the first time the application is being launched. ```APIDOC ## isFirstStart() ### Description Check if this is the first application launch (properties file didn't exist). ### Method `public static synchronized boolean isFirstStart()` ### Return `boolean` — true if first start ### Request Example ```java if (Settings.isFirstStart()) { // Show welcome dialog showWelcomeDialog(); } ``` ``` -------------------------------- ### Start DavGateway Application Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/DavGateway.md Launches the DavMail application. Can be used to start in server mode with a custom configuration file, with default GUI and configuration, or to extract an OAuth refresh token. ```java DavGateway.main(new String[]{"server", "/etc/davmail/davmail.properties"}); ``` ```java DavGateway.main(new String[]{}); ``` ```java DavGateway.main(new String[]{"token"}); ``` -------------------------------- ### Log Format Example Source: https://github.com/mguessan/davmail/blob/master/_autodocs/configuration.md This is the standard log format used by DavMail, configured via log4j properties. ```text [TIMESTAMP] [LEVEL] [Logger] Message ``` -------------------------------- ### Get String Property Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Retrieves a string property value by its key. A default value can be provided if the key is not found. ```java public static String getProperty(String key) public static String getProperty(String key, String defaultValue) ``` ```java String url = Settings.getProperty("davmail.url"); String mode = Settings.getProperty("davmail.mode", "EWS"); ``` -------------------------------- ### Create Custom Protocol Server and Connection Source: https://github.com/mguessan/davmail/blob/master/_autodocs/INDEX.md Extend AbstractServer and AbstractConnection to implement a custom protocol. Define the server's name, port, protocol name, and connection handling logic. ```java // Extend AbstractServer public class CustomServer extends AbstractServer { public CustomServer(int port) { super("CustomServer", port, 9999); // default port 9999 } @Override public String getProtocolName() { return "CUSTOM"; } @Override public AbstractConnection createConnectionHandler(Socket socket) { return new CustomConnection(socket); } } // Extend AbstractConnection public class CustomConnection extends AbstractConnection { public CustomConnection(Socket socket) { super("CustomConnection", socket); } @Override public void run() { try { while ((line = readLine()) != null) { handleCommand(line); } } finally { close(); } } } ``` -------------------------------- ### run() Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/AbstractServer.md The main server loop that continuously accepts incoming client connections and initiates handlers for them. This method is intended to run on the server thread and should not be overridden by subclasses. Protocol logic should reside in an `AbstractConnection` subclass. ```APIDOC ## run() ### Description Main server loop. Accepts incoming client connections and creates handlers. ### Method GET (conceptual) ### Endpoint N/A (Method call) ### Behavior: - Continuously accepts new client connections - For each connection, calls `createConnectionHandler()` - Starts the connection handler thread - Continues until `close()` is called ### Thread Safety: Runs on server thread; thread-safe with sockets ### Notes: - Subclasses should NOT override `run()` - Protocol logic belongs in `AbstractConnection` subclass ``` -------------------------------- ### SSL/TLS Configuration Source: https://github.com/mguessan/davmail/blob/master/_autodocs/INDEX.md Configure SSL/TLS settings for secure connections. Provide the path to the keystore file and its password. ```properties davmail.ssl.keystoreFile=/path/to/keystore davmail.ssl.keystorePass=password ``` -------------------------------- ### PopServer Constructor Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/ProtocolServers.md Initializes a PopServer instance. Use port 0 to default to port 110. ```java public PopServer(int port) ``` -------------------------------- ### Get Integer Property Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Retrieves an integer property value by its key. A default integer value can be provided if the key is not found or invalid. ```java public static int getIntProperty(String key) public static int getIntProperty(String key, int defaultValue) ``` ```java int smtpPort = Settings.getIntProperty("davmail.smtpPort"); int timeout = Settings.getIntProperty("davmail.timeout", 30); ``` -------------------------------- ### Application Lifecycle Source: https://github.com/mguessan/davmail/blob/master/_autodocs/INDEX.md Documentation for the main application entry point and its lifecycle management methods. ```APIDOC ## DavGateway ### Description Main application entry point for DavMail. ### Methods - `main(String[] args)`: Starts the application with provided arguments. - `start()`: Initiates all server processes. - `stop()`: Gracefully shuts down the application. - `restart()`: Reloads the application configuration. ``` -------------------------------- ### Dynamically Reconfigure Settings and Persist Changes Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Shows how to dynamically change a setting, persist the changes to the configuration file, update logging, and trigger a restart of the DavGateway. ```java // Change setting Settings.setProperty("davmail.imapPort", "1143"); // Persist to file Settings.saveSettings(); // Update log config if changed Settings.updateLoggingConfig(); // Trigger restart DavGateway.restart(); ``` -------------------------------- ### Set DavMail Configuration File Path Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Specify the custom path for the davmail.properties file before loading. This is useful for non-standard installation locations. ```java public static synchronized void setConfigFilePath(String path) ``` ```java Settings.setConfigFilePath("/etc/davmail/davmail.properties"); Settings.load(); ``` -------------------------------- ### SMTP Server Health Check in Java Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/ProtocolServers.md Instantiate, bind, and start an SmtpServer in Java. Includes checks for server status and graceful shutdown. ```java SmtpServer smtpServer = new SmtpServer(0); smtpServer.bind(); smtpServer.start(); // Check if running if (smtpServer.isAlive()) { System.out.println("SMTP running on port " + smtpServer.getPort()); } // Stop gracefully smtpServer.close(); try { smtpServer.join(); // Wait for thread to exit } catch (InterruptedException e) { Thread.currentThread().interrupt(); } ``` -------------------------------- ### Implement Main Connection Loop Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/AbstractConnection.md The run method is an abstract method that must be implemented by subclasses. It forms the main connection loop, responsible for reading commands, authenticating users, executing commands, sending responses, handling errors, and ensuring a clean closure. ```java public abstract void run() ``` ```java @Override public void run() { sendLine("* OK IMAP4rev1 server ready"); String line; try { while ((line = readLine()) != null) { String[] parts = line.split(" ", 2); String command = parts[0]; String args = parts.length > 1 ? parts[1] : ""; switch (command) { case "LOGIN": handleLogin(args); break; case "SELECT": handleSelect(args); break; case "LOGOUT": sendLine("* BYE Server closing"); return; } } } catch (IOException e) { LOGGER.debug("Connection error: " + e.getMessage()); } finally { close(); } } ``` -------------------------------- ### Get Microsoft Graph API Base URL Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Retrieves the base URL for the Microsoft Graph API. This is used for interacting with Microsoft Graph services. ```java public static String getGraphUrl() ``` -------------------------------- ### Get Character Array Property Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Retrieves a sensitive property, such as a password, as a character array for enhanced security. Use this for properties that should not persist in memory as strings. ```java public static char[] getCharArrayProperty(String key) ``` ```java char[] keystorePass = Settings.getCharArrayProperty("davmail.ssl.keystorePass"); // Use password Arrays.fill(keystorePass, '0'); // Clear ``` -------------------------------- ### Get Boolean Property Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Retrieves a boolean property value by its key. Recognizes 'true', 'yes', 'on' (case-insensitive). A default boolean value can be provided. ```java public static boolean getBooleanProperty(String key) public static boolean getBooleanProperty(String key, boolean defaultValue) ``` ```java boolean server = Settings.getBooleanProperty("davmail.server", false); boolean tray = Settings.getBooleanProperty("davmail.enableTray", true); ``` -------------------------------- ### SMTP Connection with STARTTLS Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/ProtocolServers.md Connects to an SMTP server using STARTTLS on the default port (25). ```bash # SMTP with STARTTLS openssl s_client -starttls smtp -connect localhost:25 ``` -------------------------------- ### getInstance Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/ExchangeSessionFactory.md Gets a valid Exchange session. If the current session is expired or invalid, it creates a new one. This method is useful for maintaining long-running connections. ```APIDOC ## getInstance(ExchangeSession currentSession, String userName, String password) ### Description Gets a valid Exchange session, creating a new one if the current session is expired. ### Method `public static ExchangeSession getInstance(ExchangeSession currentSession, String userName, String password)` ### Parameters #### Path Parameters - **currentSession** (ExchangeSession) - Required - Currently active session - **userName** (String) - Required - Exchange user login - **password** (String) - Required - Exchange user password ### Return `ExchangeSession` — Valid authenticated session ### Behavior: - Checks if current session is expired - If not expired, returns current session immediately - If expired, removes from pool and creates new session - Useful for long-running connections ### Example: ```java ExchangeSession session = ExchangeSessionFactory.getInstance("user", "password"); // ... use session // Refresh session if needed session = ExchangeSessionFactory.getInstance(session, "user", "password"); ``` ``` -------------------------------- ### ImapServer Constructor Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/ProtocolServers.md Initializes the IMAP server. Use port 0 to use the default port 143. ```java public ImapServer(int port) ``` -------------------------------- ### PopServer Constructor Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/ProtocolServers.md Initializes a PopServer instance. The port parameter allows specifying the listening port for POP3 connections. ```APIDOC ## PopServer Constructor ### Description Initializes a PopServer instance. The port parameter allows specifying the listening port for POP3 connections. ### Method ```java public PopServer(int port) ``` ### Parameters #### Path Parameters - **port** (int) - Required - POP3 listen port (0 = use default 110) ``` -------------------------------- ### Get Office365 EWS Endpoint URL Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/Settings.md Retrieves the default Office365 Exchange Web Services (EWS) endpoint URL. Use this as a default for EWS connections. ```java public static String getO365Url() ``` ```java String url = Settings.getO365Url(); // Use as default ``` -------------------------------- ### Get or Create Exchange Session Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/ExchangeSessionFactory.md Retrieves a valid Exchange session. If the current session is expired, it creates a new one. Useful for maintaining long-running connections. ```java public static ExchangeSession getInstance(ExchangeSession currentSession, String userName, String password) throws IOException ``` ```java ExchangeSession session = ExchangeSessionFactory.getInstance("user", "password"); // ... use session // Refresh session if needed session = ExchangeSessionFactory.getInstance(session, "user", "password"); ``` -------------------------------- ### Get Current DavMail Version Source: https://github.com/mguessan/davmail/blob/master/_autodocs/api-reference/DavGateway.md Retrieves the current version of the DavMail application from the JAR manifest. Returns an empty string if the version is not defined, such as in development builds. ```java String version = DavGateway.getCurrentVersion(); if (!version.isEmpty()) { System.out.println("DavMail version " + version); } ```