I am trying to write a simple java program to send email using JavaMail API. I have put mail.jar in my class path and used the following code for the same.
When i try to compile the above code , i get the following compilation error.
I can not understand why this error is coming.i manually tested the connectivity with our mail server using ping utility.But i am not sure why i am not able to connect to port 25(SMTP) . Can any body predict why this error is coming and suggest a solution?
Ping just checks that the machine is up and running, and listening to the network. If you can't connect to port 25, that port may be blocked somewhere in between, or the mail server is down or doesn't accept connections from the machine you're trying this from. You said that your mail client running on the same machine does not have problems connecting to that machine? That would be odd indeed.
You said that your mail client running on the same machine does not have problems connecting to that machine?
yes, A mail client(Lotus Notes) is running in the same machine which is connected to that machine through which we send and receive our corporate mails. But i can not programmatically connect to that machine on port 25. Do i need to do any configuration in mail server to accept connection from my machine or is there any problem in sending mails from a system which is behind the firewalls?
Check your Notes client configuration. Somewhere it is likely to describe its connection parameters (sorry, can't suggest where - I haven't used Notes in six years). Perhaps you are connecting to the wrong machine, or there are extra authentication steps needed.
(Long shot: make sure your email server is running Domino 4.5 or above, previous versions didn't support SMTP)
The port 25 is usually blocked by the SMTP/POP3 server and checkbox is usually set. Tell your Administrator to uncheck this. Normally this port is blocked as part of the 6 port blocking rules as set in the virusscan console of the POP3/SMTP Server for your IP address/machine.
Even if you uncheck the box, it re-checks the status of blocking this port after a pre-determined time.
The process has to be repeated after every "n" hours or so.