public class SendMail {
public static void main(String[] args) {
try {
Properties p = new Properties(); //Properties p = System.getProperties();
p.put("mail.smtp.auth", "true");
p.put("mail.transport.protocol", "smtp");
p.put("mail.smtp.host", "smtp.163.com");
p.put("mail.smtp.port", "25");
//寤虹珛浼氳瘽
Session session = Session.getInstance(p);
Message msg = new MimeMessage(session); //寤虹珛淇℃伅
msg.setFrom(new InternetAddress("skiyra@163.com")); //鍙戜歡浜?
msg.setRecipient(Message.RecipientType.TO, new InternetAddress("myb4562@163.com")); //鏀朵歡浜?
msg.setSentDate(new Date()); // 鍙戦佹棩鏈?
msg.setSubject("絳旇瘽紼鏈?); // 涓婚
msg.setText("蹇偣涓嬪湪"); //鍐呭
// 閭歡鏈嶅姟鍣ㄨ繘琛岄獙璇?
Transport tran = session.getTransport("smtp");
tran.connect("smtp.163.com", "skiyra", "aaaaaaaaaaaa");
// bluebit_cn鏄敤鎴峰悕錛寈iaohao鏄瘑鐮?
tran.sendMessage(msg, msg.getAllRecipients()); // 鍙戦?
System.out.println("閭歡鍙戦佹垚鍔?);
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} //鍙戜歡浜?
}
}

]]>