看了javamail的一些資料,挺麻煩的,仍是commons的比較簡單.貼上代碼:(只是還沒學會發附件,但如今發附件都要超大附件了,恐怕仍是用客戶端比較簡單)java
public static void main(String[] args) {
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.163.com");//設置使用發電子郵件的郵件服務器
try {
email.addTo("49947883@qq.com");
email.setAuthentication("email@163.com","password");
email.setFrom("email@163.com");
email.setSubject("Test apache.commons.mail message");
email.setMsg("This is a simple test of commons-email");
email.send();
}
catch (EmailException ex) {
ex.printStackTrace();
}
}apache