无法使用JavaMail、Exchange Server和SMTP发送电子邮件

无法使用JavaMail、Exchange Server和SMTP发送电子邮件,smtp,exchange-server,jakarta-mail,Smtp,Exchange Server,Jakarta Mail,我正在尝试使用以下代码使用JavaMail、Exchange Server和SMTP发送邮件: Properties props = new Properties(); props.put("mail.smtp.auth", true); props.put("mail.smtp.starttls.enable", true); props.put("mail.smtp.host", host);

我正在尝试使用以下代码使用JavaMail、Exchange Server和SMTP发送邮件:

            Properties props = new Properties();
            props.put("mail.smtp.auth", true);
            props.put("mail.smtp.starttls.enable", true);
            props.put("mail.smtp.host", host);
            props.put("mail.smtp.port", port);

            Session session = Session.getInstance(props,
                    new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username,
                            password);
                }
            });

            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from));
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse(to));
            message.setRecipients(Message.RecipientType.CC,
                    InternetAddress.parse(cc));
            message.setSubject(sub);

            MimeBodyPart messageBodyPart1 = new MimeBodyPart();
            messageBodyPart1.setContent(msg, "text/html; charset=utf-8");

            Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(messageBodyPart1);

            message.setContent(multipart);

            Transport.send(message);
获取以下错误,请帮助:

com.sun.mail.smtp.SMTPSendFailedException:550 5.7.1客户端不存在 具有发送权限,因为已引发此发件人异常: com.sun.mail.smtp.SMTPSendFailedException:550 5.7.1客户端不存在 具有作为此发件人发送的权限

我已于2014年7月7日更改了用户详细信息,现在出现以下错误:

已引发异常:javax.mail.MessaginException:连接 被服务器丢弃?;嵌套异常为:java.io.IOException: 服务器断开的连接


您使用的是什么版本的JavaMail?协议跟踪显示了什么?您确定要对服务器进行身份验证吗


如果您使用的是较旧版本的JavaMail,则需要将属性设置为字符串,而不是布尔常量。

我使用的是JavaMail 1.5.1。所有详细信息,如凭据、身份验证,都是绝对正确的。在我的问题中添加了错误详细信息。您可以发布错误信息吗?