Sunday, February 14, 2010

Programmer - how to send mail Spring implemention using gmail smtp?

Programmer Question

how to send mail Spring implemention using gmail smtp?



After executing main method getting exeception
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/FileTypeMap



public static void main(String[] args) {
JavaMailSenderImpl sender = new JavaMailSenderImpl();
sender.setHost("smtp.gmail.com");
sender.setPort(25);
sender.setPassword("xxxxxxx");
sender.setUsername("businesscaliber@gmail.com");

MimeMessage message = sender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(message);
helper.setTo("yashwantchavan@gmail.com");
helper.setText("Thank you for ordering!");
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

sender.send(message);
}


After putting activation.jar in class path getting this exception



javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. 21sm3277189pzk.7

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails