通过消息发送电子邮件
//n o w j a v a . c o m - 时代Java 提供 import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import java.util.Properties; public class Main{ private static Session session = getSession(); public static void sendEmail(String subject, String body) { try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("from@gmail.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("asdf@gmail.com")); message.setSubject(subject); message.setText(body); Transport.send(message); System.out.println("Done");/** 时代Jav