Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaMail e-mail goes to Junk E-mail

 
Vivek Alampally
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
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.

Can anyone here know how to rectify this problem.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vivek Alampally
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
 
Rangana Minesh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try With this Code


String from = "test@gmail.com";
String to = "test@abc.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
props.put("mail.smtp.host", host);
// To see what is going on behind the scene
props.put("mail.debug", "true");
Session session = Session.getInstance(props);

try {
// Instantiatee a message
Message msg = new MimeMessage(session);

//Set message attributes
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("ONLINE SHOPPING DETAILS ");
msg.setSentDate(new Date());




}
msg.setContent("<h1> Online Shopping Details</h1>", "text/html");


//Send the message
Transport.send(msg);
}

catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
mex.printStackTrace();
}

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rangana Minesh wrote:
msg.setSubject("ONLINE SHOPPING DETAILS ");
msg.setContent("<h1> Online Shopping Details</h1>", "text/html");

Having an all-uppercase subject, using HTML, and repeating the words "online shopping" are all excellent ways to increase the likelihood of an email being classified as spam.
 
Vivek Alampally
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Here's the Wikipedia article: Simple Mail Transfer Protocol.
 
Mahendra Hegde
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vivek Alampally,
Please can you tell me what changes you have done to fix the issue in your code.
Even my application mail is going to junk mail in some mail id's (mail is having image)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic