彭先生,javaMail的問題

wyq發表於2004-10-20
我想用javaMail實現郵件傳送的功能,可是失敗,程式執行後,
wenxinjiang2008@yahoo.com.cn信箱裡沒收到郵件,請幫我修改一下。程式碼如下:
public static void main(String[] args){
Properties props=new Properties();
props.put("mail.smtp.host","zhaominglun_cc@126.com");
Session session=Session.getDefaultInstance(props);
MimeMessage message=new MimeMessage(session);
try{
Address address=new InternetAddress("zhaominglun_cc@126.com");
Address toAddress=new InternetAddress("wenxinjiang2008@yahoo.com.cn");
message.setFrom(address);
message.setRecipient(MimeMessage.RecipientType.TO,toAddress);
message.setSubject("Hello,妹妹!");
message.setSentDate(new Date());
message.setText("你在幹什麼呢?");
Transport transport=session.getTransport("smtp");
transport.send(message);
}catch(Exception e){}
}

相關文章