Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mails sent via SendMail facility in Linux going to spam folder

 
Sherin Ramy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
The emails that I have been sending via sendmail using Javamail are going into Spam folder.My username is from gmail.So it goes to other gmail users perfectly.It doesn't work with yahoo or hotmail or any other email sites.It lands in Junk.Has anyone ever come across this issue.
I have attached the code
boolean debug = false;

//Set the host smtp address
Properties props = new Properties();
//System.out.println("The localhost is"+SMTP_HOST_NAME);
//props.put("mail.smtp.host",SMTP_HOST_NAME);
props.put("mail.smtp.localhost", "*IP added here*");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");


Authenticator auth = new SMTPAuthenticator();
//I have a SMPTPAuthenticator class that is used for Authentication

Session session = Session.getDefaultInstance(props, auth);
//Session session = Session.getDefaultInstance(props, null);

session.setDebug(debug);

// create a message
Message msg = new MimeMessage(session);

// set the from and to address
System.out.println("The from address is"+from);
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);

InternetAddress addressTo= new InternetAddress(recipient);
System.out.println("The to address is"+recipient);
msg.setRecipient(Message.RecipientType.TO,
addressTo);



// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);





Much thanks in advance for the help.
 
Lester Burnham
Rancher
Posts: 1337
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which SMTP server are you using? Gmail? Or are you running your own? If the latter, then the MX record of the mail server responsible for the email address you're using (Gmail) doesn't vibe with the sending mail server, and that's often seen as an indicator of spam.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to JavaRanch
 
Sherin Ramy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help.
 
Sherin Ramy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sheriff.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic