我用公司的用户名在公司的企业邮局里可以任意的发邮件,可是用"smtp.163.com"或者其他的就不可以发了。而且还出了个异常
java.lang.SecurityException:Access to default session denied请问各位高手,这是咋回事啊?(163的用户名和密码都是正确的)

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【xiaoxiao1987918】截止到2008-07-10 17:39:01的历史汇总数据(不包括此帖):
    发帖的总数量:4                        发帖的总分数:80                       每贴平均分数:20                       
    回帖的总数量:2                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:1                        结贴的总分数:20                       
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:3                        未结的总分数:60                       
    结贴的百分比:25.00 %               结分的百分比:25.00 %                  
    无满意结贴率:0.00  %               无满意结分率:0.00  %                  
    楼主该结一些帖子了
      

  2.   

    有时候要看你的163邮箱帐号知否支持smtp功能。现在126就有这种限制,在2006年还是2007年几月份开始申请的新邮箱都不能使用POP3功能,非常郁闷。
      

  3.   


    有谁能帮我看看代码,还有哪里没注意到的???
    //身份验证类
    package com.rlis.model;import javax.mail.PasswordAuthentication;/**
     * Eway邮件认证信息
     * 
     */
    public class EwayAuthenticator extends javax.mail.Authenticator {
     private String account; //帐号
     private String password; //密码 /**
      * 构造函数赋值
      * @param user 帐号
      * @param password 密码
      */
     public EwayAuthenticator(String user, String password) {
      this.account = user;
      this.password = password;
     } protected PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication(account, password);
     } /**
      * @return the account
      */
     public String getAccount() {
      return account;
     } /**
      * @return the password
      */
     public String getPassword() {
      return password;
     }
    }
    //发送邮件方法
    public boolean sendEmail(String smtpServer, EwayAuthenticator authenticator, EmailInfo emailInfo)
       throws UserException
     {  
      logger.info("Sendinging email message: (fromAddress:"+authenticator.getAccount()+"," +
        "toAddress:"+((InternetAddress)emailInfo.getToAddresses()[0]).getAddress()+")");
      boolean returnResult = false;
      Properties props = System.getProperties();
      try {
       props.put("mail.smtp.host", "stmp.sina.com");
       props.put("mail.smtp.port", 25);
       
       // Get session
       props.put("mail.smtp.auth", "true"); // 这样才能通过验证
       
       EwayAuthenticator myauth = new EwayAuthenticator(authenticator.getAccount(),authenticator.getPassword());
       Session session = Session.getDefaultInstance(props, myauth);    Message msg = new MimeMessage(session);
       msg.setFrom(new InternetAddress(authenticator.getAccount()));
       msg.setRecipients(javax.mail.Message.RecipientType.TO, emailInfo.getToAddresses());    
       msg.setSubject(emailInfo.getSubject());
       msg.setHeader("X-Mailer", "regmailer");
       msg.setSentDate(new Date());
       msg.setDataHandler(new DataHandler(emailInfo.getContent(), "text/html"));   
       Transport tran = (Transport) session.getTransport("smtp");
       tran.connect(smtpServer,authenticator.getAccount(),authenticator.getPassword());
       tran.send(msg);
      } catch (Exception ex) {
       logger.error("Error sending email message: "+ ex);
       throw new UserException("Error sending email message: "
         + ex);
      }
     }
      

  4.   

    围绕我几天的问题解决了!!!呵呵不是代码的问题,是 server的问题,把weblogic 服务重启一次就可以发了!
      

  5.   

    我看了自己的代码,我用的是m_objSession = Session.getInstance(m_properties,m_objAuthenticator);
    其他一模一样,呵呵好久没有用了,刚刚试一下,还可以发出去我的是126的邮箱