public class DefaultMailNotifierTest {
private boolean online = false;
@Test
public void testGmail() throws Exception {
JavaMailSenderImpl mailSender = new org.springframework.mail.javamail.JavaMailSenderImpl();
mailSender.setHost("smtp.gmail.com");
mailSender.setUsername("eams.demon");
mailSender.setPassword("eamsadmin");
mailSender.setPort(465);
mailSender.setProtocol("smtp");
// Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
mailSender.getJavaMailProperties().put("mail.smtp.auth", "true");
mailSender.getJavaMailProperties().put("mail.smtp.port", new Integer(465));
mailSender.getJavaMailProperties().put("mail.smtp.starttls.enable", "true");
mailSender.getJavaMailProperties().put("mail.smtp.socketFactory.port", new Integer(465));
mailSender.getJavaMailProperties().put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
mailSender.getJavaMailProperties().put("mail.smtp.socketFactory.fallback", "false");
MailMessage mmc = new MailMessage("eams.demon@gmail.com", "测试", "测试简单邮件发送机制");
DefaultMailNotifier mailNotifier = new DefaultMailNotifier();
mailNotifier.setJavaMailSender(mailSender);
mailNotifier.setFromMailbox("eams.demon@gmail.com");