βThe strongest of all warriors are these two β Time and Patience.β β Leo Tolstoy, War and Peace
Matt Wong wrote:Hi Comal,
as I'm a bit more into the whole topic about java and e-mail I can give you some input:
It seems you're tryin to connect to the server directly instead of use java mail api. I recommend you to use it. It handles many things for you so you don't have to speak smtp to the target server directly.
So I guess your code some looks some like this:
Rather strange your Source is over 370 lines long but the very basics doesn't work.
There're a couple of reasons the connection is refused:
- You're tryin to directly connect to the target SMTP server - and maybe this connection gets refused cause the server only accepts connections from other "registered" SMTP servers but refuses connections from private IP ranges - simple spam protection.
- If you're try to connect to a SMTP server of your mail provider - you maybe try to connect to the wrong port. A SMTP server usualy has following ports opened:
TCP/25 - to receive mails from other SMTP servers - normaly plain unencrypted - but could also provide STARTTLS feature
TCP/465 - to accept mail-submission from registered clients - secured by socket level TLS
TCP/587 - same as above - but mostly used with STARTTLS command instead of socket level TLS
Here's a sample:
Obviously you need java mail api in your classpath to compile and run.
Try to get my sample working - and post stacktraces if you encounter exceptions so we can narrow down the problem.
Hope it helps in any way.
Matt
Matt Wong wrote:Well, I wouldn't try to implement raw smtp by myself - use java mail lib instead.
Did you tried to telnet localhost:25 ?
This might work on a linux machine as usual there should be a mail deamon runnung - but on windows you have to setup a mail server first as windows doesn't have any MTA pre-installed.
Anyway: we still need some more information to help you.
Matt Wong wrote:Well, I wouldn't try to implement raw smtp by myself - use java mail lib instead.
Did you tried to telnet localhost:25 ?
This might work on a linux machine as usual there should be a mail deamon runnung - but on windows you have to setup a mail server first as windows doesn't have any MTA pre-installed.
Anyway: we still need some more information to help you.
Matt Wong wrote:Hi Comal,
as I'm a bit more into the whole topic about java and e-mail I can give you some input:
It seems you're tryin to connect to the server directly instead of use java mail api. I recommend you to use it. It handles many things for you so you don't have to speak smtp to the target server directly.
Matt
Matt Wong wrote:Well, I wouldn't try to implement raw smtp by myself - use java mail lib instead.
Did you tried to telnet localhost:25 ?
This might work on a linux machine as usual there should be a mail deamon runnung - but on windows you have to setup a mail server first as windows doesn't have any MTA pre-installed.
Anyway: we still need some more information to help you.
Consider Paul's rocket mass heater. |