当我使用Javamail发送邮件时,通过SMTP认证的是用户A,但是发信人是B,当发信的时候产生一个异常,提示Your envelope sender is different from the authuser,这个问题如何解决?请各位帮忙,谢谢。
  String smtpServer = "smtpServer";//smtp服务器
        String smtpAuth = "true";//smtp服务器是否需要进行验证
        String smtpUser = "authUser";//smtp分配的用户名(就是你的E-Mail地址中@符号前面部分)
        String smtpPassword = "pass";//登陆口令
        String from = "sender";//用于在对方收到的邮件中作为发送人地址显示
        String to = mailTo;//邮件需要发送到的目标邮件地址
        String subject = mailSubject;//邮件主题
        String text = mailBody;//邮件体,在这里是邮件正文
        Properties props = new Properties();//构造Properties,作为后面的Session参数容器
        Session sendMailSession;
        Transport transport;
        props.put("mail.smtp.host", smtpServer);
        props.put("mail.smtp.auth", smtpAuth);
        if ("true".equals(smtpAuth)) {
          //如果smtp服务器需要验证,则构建AuthertiactorUtil用于mail session的创建
         AuthenticatorUtil authutil = new AuthenticatorUtil(smtpUser, smtpPassword);
          sendMailSession = Session.getInstance(props, authutil);
        }
        else {
          sendMailSession = Session.getInstance(props);
        }        //设置是否是调试状态,如果这里设置为true的话,则会在控制台输出发送过程,输出信息类似于在telnet上发送邮件
        sendMailSession.setDebug(true);
        //初始化邮件消息
        Message message = new MimeMessage(sendMailSession);
        message.setFrom(new InternetAddress(from));
        message.setRecipient(Message.RecipientType.TO,
                                new InternetAddress(mailTo));
        message.setSubject(subject);
        message.setSentDate(new Date());
        message.setText(text);
        message.saveChanges();
        transport = sendMailSession.getTransport("smtp");//此次会话是发送邮件(smtp)
        transport.send(message, message.getAllRecipients());//从这里可以看出来,可以设置多个发送目的地址
        transport.close();