[java]代码库
Properties props = new Properties();
props.setProperty("mail.host", host);
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.auth", "true");
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.ssl.socketFactory", sf);
Session session = Session.getInstance(props);
session.setDebug(true);
Transport ts = session.getTransport();
ts.connect(host, username, password);
Message message = createEmail(session,managers);
ts.sendMessage(message, message.getAllRecipients());
ts.close();
[源代码打包下载]