Thank you for your suggestions!
My understanding from your suggestions is that you do not want me to make any corrections on the client code. I just need to make corrections on the Nginx configuration as per the blog link.
I am trying to understand that blog, going through again and again. so far I understand that it creates a SSL layer first through which it accepts the client request. Client should point to my proxy host and one of the ports listed under "mail{... }". Proxy server identifies the upstream host based on the username came from the client request. Then the call is routed to actual upstream host based on the port. Please correct me if I am wrong anywhere.
My questions are
1) Significance of this line "auth_http localhost:9000/cgi-bin/nginxauth.cgi;" is just to have my own authorization logic and return the valid upstream server host based on the username. Is it correct?
2) I want to know what does this mean "smtp_auth login plain cram-md5;". Does the connection to actual upstream happen here?
Please help me on this and also share links supporting the above configuration.