Since you're trying to connect to "localhost", you must have a mail server under your control on your local machine. Can you connect to it using other means (e.g. a mail client)? Do any messages show up in its log files?
Originally posted by kwame Iwegbue: I'm not trying to connect through local host.
But the debug output from JavaMail says specifically
trying to connect to host "localhost", port 25
You need to set the "smtp.mail.host" property to the name or IP address of the computer where your SMTP server is running. Check with its administrator if you are not sure of what name or address you should be using.
Originally posted by kwame Iwegbue: Thank you paul.
so i guess from a regular desktop/private computer, that would be "localhost".
Yes, but you should ofcourse have mail server software running on your regular desktop/private computer (i.e., localhost) if you want to do that. If you don't have mail server software running, it's not going to work. Have a look at Apache Jakarta James for example, a free and open source mail server.
Originally posted by kwame Iwegbue: props.put("smtp.mail.host", host);
I thought this refers to the receipients smtp and host. for example when sending mail to someone with yahoo email, then should use props.put("smtp.yahoo.com", 'mail.yahoo.com'); or something like this
No, it would be:
if mail.yahoo.com is indeed an SMTP mail server that you can access. [ January 16, 2006: Message edited by: Jesper de Jong ]
Originally posted by kwame Iwegbue: so i guess from a regular desktop/private computer, that would be "localhost".
Here's how e-mail works. You give your e-mail message to a mail server and tell it who the recipients are. It finds their mail server, if it can, and between the two servers your message gets transferred from your server to the recipients' server.
Now here's the problem with that idea. All of those e-mail servers are accessible from the Internet. They have to be so that they can find each other and transfer messages. That means that anybody anywhere on the Internet can connect to any e-mail server and ask it to send a message to anybody else. This ability has been abused by people named "spammers" who use other people's servers to send out mass mailings that try to cheat people. So public e-mail servers won't let your program use them to send messages unless you have been pre-approved in some way.
In your case you don't have your own server. And even if you install your own server it probably isn't going to be trusted by other servers, for various technical reasons (I'm not writing an entire magazine article here). If you don't have access to an SMTP server that already exists, then you are wasting your time. If you are writing this program for a company, then that company should have an e-mail server that you can use. As I already said, you need to talk to the administrator of that server to get yourself approved to use it. But if you're just writing it for personal use, you are going to find it a lot more difficult to get access to a server.