@Test public void testSend() throws Exception { String host = "smtp.qq.com"; MailManager mailManager = new SMTPMailManagerImpl(host, "2179816070@qq.com", "这里是授权码", "LTS通知中心(notice@lts.com)", true); mailManager.send("254963746@qq.com", "测试", "fdsafhakdsjfladslfj呵呵呵"); }
public void send(String to, String title, String message) throws Exception { Session session = Session.getDefaultInstance(properties, getAuthenticator()); MimeMessage mimeMessage = new MimeMessage(session); mimeMessage.setFrom(new InternetAddress(adminAddress)); mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); mimeMessage.setSubject(title); mimeMessage.setText(message); Transport.send(mimeMessage); }
SMTPMailManagerImpl implements MailManager { public void send(String to, String title, String message) throws Exception { Session session = Session.getDefaultInstance(properties, getAuthenticator()); MimeMessage mimeMessage = new MimeMessage(session); mimeMessage.setFrom(new InternetAddress(adminAddress)); mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); mimeMessage.setSubject(title); mimeMessage.setText(message); Transport.send(mimeMessage); } }
SMTPMailManagerImpl implements MailManager { public void send(String to, String title, String message) throws Exception { Session session = Session.getDefaultInstance(properties, getAuthenticator()); MimeMessage mimeMessage = new MimeMessage(session); mimeMessage.setFrom(new InternetAddress(adminAddress)); mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); mimeMessage.setSubject(title); mimeMessage.setText(message); Transport.send(mimeMessage); } SMTPMailManagerImpl(String host, String userName, String password,
                               String adminAddress, boolean sslEnabled);  SMTPMailManagerImpl(String host, String port, String userName, String password,
                               String adminAddress, boolean sslEnabled); }
SMTPMailManagerImpl implements MailManager { public void send(String to, String title, String message) throws Exception { Session session = Session.getDefaultInstance(properties, getAuthenticator()); MimeMessage mimeMessage = new MimeMessage(session); mimeMessage.setFrom(new InternetAddress(adminAddress)); mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); mimeMessage.setSubject(title); mimeMessage.setText(message); Transport.send(mimeMessage); } SMTPMailManagerImpl(String host, String userName, String password,
                               String adminAddress, boolean sslEnabled);  SMTPMailManagerImpl(String host, String port, String userName, String password,
                               String adminAddress, boolean sslEnabled); void send(String to, String title, String message); }
SMTPMailManagerImpl implements MailManager { public void send(String to, String title, String message) throws Exception { Session session = Session.getDefaultInstance(properties, getAuthenticator()); MimeMessage mimeMessage = new MimeMessage(session); mimeMessage.setFrom(new InternetAddress(adminAddress)); mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); mimeMessage.setSubject(title); mimeMessage.setText(message); Transport.send(mimeMessage); } SMTPMailManagerImpl(String host, String userName, String password,
                               String adminAddress, boolean sslEnabled);  SMTPMailManagerImpl(String host, String port, String userName, String password,
                               String adminAddress, boolean sslEnabled); void send(String to, String title, String message);  }