Vikings

重温javaMail


1。服务系统不需要验证发件人的授权的
    Session session = Session.getDefaultInstance(props, null); 
2。要验证发件人的授权
    props.put("mail.smtp.auth", "true"); 
    MyAuthenticator myauth = new MyAuthenticator("你自己的电子信箱", "你自己的信箱密码");
    Session session = Session.getDefaultInstance(props, myauth);
3。同时发送多封电子邮件
Transport.send(message);可以使用下面的代码来代替
      String username = "你的电子信箱用户名";
      String password = "你的电子信箱密码";
      message.saveChanges(); //    implicit with send()
      Transport transport = session.getTransport("smtp");
      transport.connect("mail.htf.com.cn", username, password);
      transport.sendMessage(message, message.getAllRecipients());
      transport.close();

Communication Component,温习。
http://www.china1024.com/news_content.jsp?news_id=1060

posted on 2006-11-28 11:33 Vikings 阅读(169) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: