String address = null;
String host = null; String user = null;
    public static InternetAddress getLocalAddress(Session session) {        String address = null;        if (session != null) {            address = session.getProperty("mail.from");            if (address == null) {                String user = session.getProperty("mail.user");                String host = session.getProperty("mail.host");                if (user != null && host != null) {                    address = user + '@' + host;                }            }        }        if (address == null) {            try {                String user = System.getProperty("user.name");                String host = InetAddress.getLocalHost().getHostName();                if (user != null && host != null) {                    address = user + '@' + host;                }            } catch (UnknownHostException e) {                // ignore            } catch (SecurityException e) {                // ignore            }        }        if (address != null) {            try {                return new InternetAddress(address);            } catch (AddressException e) {                // ignore            }        }        return null;    }