posted 14 years ago
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.