*
The moose likes Java in General and the fly likes Mails sent via SendMail facility in Linux going to spam folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Mails sent via SendMail facility in Linux going to spam folder " Watch "Mails sent via SendMail facility in Linux going to spam folder " New topic
Author

Mails sent via SendMail facility in Linux going to spam folder

Sherin Ramy
Greenhorn

Joined: Dec 07, 2010
Posts: 5
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

Joined: Oct 14, 2008
Posts: 1337
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

Joined: Oct 13, 2005
Posts: 38460
    
  23
. . . and welcome to JavaRanch
Sherin Ramy
Greenhorn

Joined: Dec 07, 2010
Posts: 5
Thanks for the help.
Sherin Ramy
Greenhorn

Joined: Dec 07, 2010
Posts: 5
Thanks Sheriff.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38460
    
  23
You're welcome
 
jQuery in Action, 2nd edition
 
subject: Mails sent via SendMail facility in Linux going to spam folder