Hi everyone,
Does anyone know if hotmail has changed their spam filter setup or something? Whenever I send emails through javamail they go in the Junk Email folder. They never used to, so i'm thinking that they've changed their spam filters.
Here's my code if it's something I'm doing wrong: -
public static void sendMail( String vsEmail )
{
boolean debug = false;
String from = "xyz@xyz.com";
String msgText1 = "Hello User,\nThese are your registration details.";
String subject = "Registration Detilas";
try
{
// create some properties and get the Session
Properties props = new Properties();
props.put("mail.smtp.host", "mail.xyz.com");
props.put("mail.smtp.auth", "true");
Session session2 = Session.getInstance(props, null);
session2.setDebug(debug);
// create a message
MimeMessage msg = new MimeMessage(session2);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = { new InternetAddress(vsEmail) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(msgText1);
// create the Multipart and add its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
// add the Multipart to the message
msg.setContent(mp);
// set the Date: header
msg.setSentDate(new Date());
// send the message
Transport transport = session2.getTransport("smtp");
transport.connect("xyz", "xyz@xyz.com", "xyz");
msg.saveChanges();
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
} catch (MessagingException mex) {
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
ex.printStackTrace();
}
}
FYI: I obviously don't use xzy as emails addresses or username / passwords but changed them for this demo