我想下面的代碼使用JavaMail,Exchange Server和SMTP發送郵件發送電子郵件:無法使用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 Client does not have permissions to send as this sender Exception has been thrown : com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.1 Client does not have permissions to send as this sender
我已經改變了對2014年7月7日的用戶資料,現在越來越以下錯誤:
Exception has been thrown : javax.mail.MessagingException: Connection dropped by server?; nested exception is: java.io.IOException: Connection dropped by server?
我正在使用JavaMail 1.5.1。 所有的細節,如憑據,身份驗證是絕對正確的。 在我的問題中添加了錯誤的詳細信息。 –
您可以發佈[協議跟蹤](http://www.oracle.com/technetwork/java/javamail/faq/index.html#debug)嗎? –