E-mail from my application directly goes to Junk e-mail. I am using Microsoft Outlook which is connected to Microsoft exchange. Dumb solution here is mark the first e-mail as Not Spam and then onwards it directly goes to Inbox.
That means that the server which receives the e-mail thinks it looks like spam. The solution, then, would be to try to make your e-mail look less like spam.
It's hard to say how you might do that when we don't know anything about how you're formatting or sending your e-mails. So all I can suggest at this point is that you should research how anti-spam products work and act accordingly.
String from = "firstname.lastname@example.org";
String to = "email@example.com";
// SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
String host = "your host ";
// Create properties, get Session
Properties props = new Properties();
// If using static Transport.send(),
// need to specify which host to send it to
// To see what is going on behind the scene
Session session = Session.getInstance(props);
// Instantiatee a message
Message msg = new MimeMessage(session);
Thanks Rangana for your code. Sorry for being this late to respond. The problem was solved before itself. I did do minor modifications to my code. And now my e-mail goes direclty to inbox.
But can any body tell me, what all should I require to send e mail to person B from a Java program,
Answer I guess would be,
1. SMTP server name
2. User id & password of smtp server
3. Reciepient mail address
I am asking this question because I am still not sure what an SMTP server does. I know when I google about it there's a lot of theory involved with it. But can anybody tell
the process involved in it in three - four lines?
Three or four lines? Don't short-change yourself. If you're going to be sending e-mail then take some time to understand the process properly. One of the reasons that 90% of the messages sent by e-mail these days are spam is, there's way too many people who set up servers without understanding what they do.