彭先生,javaMail的问题

04-10-20 wyq
我想用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){}
}

banq
2004-10-25 13:06
要设置SMTP服务器

猜你喜欢