Java mail API smtp-host automatically converting into localhost

I have below API to send smtp email:

void sendSMTPMail(File emlFile)throws Exception {
        String host = "";
        int port =25;
        Properties properties = System.getProperties();
        properties.put("", host);
        properties.put("mail.smtp.port", port);
        properties.put("mail.transport.protocol", "smtp");

        Session session = Session.getDefaultInstance(properties);
        InputStream source = new FileInputStream(emlFile);
        MimeMessage message = new MimeMessage(session,source);


When Transport.send(message) tries to send email the mentioned host say “” (some remote smtp host) automatically converting into localhost, and trying to make smtp connection at localhost, In some system its perfectly connecting with but in some system its not.
error log from system where its not working:

smtp host:, port=25.
uri in select proxy: socket://localhost:25, host: localhost
Returning previousSelector (DIRECT), host: localhost
Unable to send smtp message. MessageID: <86717532.2.1501062622633>

There is one API which tries to find proxy mapped for this smtp host but that API is receiving localhost as parameter:

public List<Proxy> select(URI uri) {
    String host = uri!=null?uri.getHost():null;"uri in select proxy: "+uri+", host: "+host);
    if (urlToProxyMap.containsKey(uri.getHost()))
        final List<Proxy> proxies = urlToProxyMap.get(uri.getHost());
        //proxy = one suitable proxy
        return proxy;
    else if (defaultProxy != null && uri.getScheme().toLowerCase().startsWith("http")) {"Returning default proxy: "+defaultProxy+", host:"+host);
        return defaultProxy;
    {"Returning previousSelector (DIRECT), host: "+host);

It could be a weird question but any pointer would be helpful