I am trying to send a mail using java mail. Below is the code:
Running the code gives the following exception:
javax.mail.MessagingException: Could not connect to SMTP host: A1DAL1SWPES20MB.ams.acs-inc.net, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1545)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:453)
at javax.mail.Service.connect(Service.java:313)
at javax.mail.Service.connect(Service.java:172)
at javax.mail.Service.connect(Service.java:121)
at javax.mail.Transport.send0(Transport.java:190)
at javax.mail.Transport.send(Transport.java:120)
at com.mail.utility.MailUtility.postMail(MailUtility.java:137)
at com.mail.utility.MailUtility.main(MailUtility.java:172)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:267)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:227)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1511)
... 8 more
doing telnet to the server :
Microsoft Telnet> open A1DAL1SWPES20MB.ams.acs-inc.net 25
Connecting To A1DAL1SWPES20MB.ams.acs-inc.net...Could not open connection to the host, on port 25: Connect failed
Question:
1. How come Microsoft Outlook is able to access the same server and send and receive mails on my system?
2. Am i right in my understanding that the above exception is because port 25 is blocked?
Regards,
Vartika.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
You're most likely behind a firewall that doesn't let any traffic through to your machine, on port 25 or any other. That's why those web sites can't connect to it, and that's exactly as it should be.
But more importantly, port 25 on your machine is irrelevant, it's port 25 on the mail server that's being used.
Are you certain that the server name and port are correct?