aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Unable to send mail through an application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Unable to send mail through an application" Watch "Unable to send mail through an application" New topic
Author

Unable to send mail through an application

vartika vaish
Greenhorn

Joined: Apr 15, 2008
Posts: 15
Hi,

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


----------------------------------------------------------------------------

using the below sites i cam eto know that port 25 is blocked on my machine:

http://www.dbapool.com/portchecker.php
http://www.canyouseeme.org/

-----------------------------------------------

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: 42289
    
  64
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?


Ping & DNS - my free Android networking tools app
vartika vaish
Greenhorn

Joined: Apr 15, 2008
Posts: 15
Are you certain that the server name and port are correct?


Yes. I think McAfee on my machine has blocked port 25 but again what i do not understand is how is outlook connecting to the same server?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Unable to send mail through an application