Send email via MS Exchange Server
843830Oct 16 2001 — edited Aug 11 2009Hi everybody!
I have:
javax.mail.MessagingException: Could not connect to SMTP host: 13.2.45.22, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: no further information
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:867)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:156)
at javax.mail.Service.connect(Service.java:234)
at javax.mail.Service.connect(Service.java:135)
at test1.SendMail.sendmail(SendMail.java:177)
at test1.SendMail.main(SendMail.java:216)
Even I can read e-mails from this server using imap protocol.
Lets put all our knowledge in one place.
What could be the reason for it?
1. MS exchange server for sending uses another port than 25. What port is it? How can I setup it within Java application.
2. What userId format should be? domain\\windowsUserId\\First.LastNames where your Outlook address is First.LastNames@domain.com
3. Is that enough to use String hostIPAddress, userID, password to connect or it's reqiued to create PasswordAuthentication passwordAuthentication = new PasswordAuthentication(userID,password );
mailSession.setPasswordAuthentication(serverUrlName,passwordAuthentication);
4. What else We can try?
Igor Artimenko
Java Programmer
Xerox