简体   繁体   English

客户端无权发送此发件人| 与JavaMail API 1.4兼容,但与1.4.7兼容

[英]Client does not have permissions to send as this sender | Works fine with JavaMail API 1.4 but not with 1.4.7

I found a similar question asked and I have same issue when sending an email with a different username than from name. 我发现了一个类似的问题,并且在发送用户名与姓名不同的电子邮件时遇到了同样的问题。 The configurations in my private exchange server are in place to mark the username as alias of the from name. 我的专用交换服务器中的配置已经就绪,可以将用户名标记为发件人名称的别名。

com.sun.mail.smtp.SMTPSenderFailedException: 550 5.7.1 Client does not have permissions to send as this sender com.sun.mail.smtp.SMTPSenderFailedException:550 5.7.1客户端没有作为该发件人的发送权限

I am able to send email with an alias when I use Java mail 1.4 version of API. 使用Java mail 1.4版本的API时,我可以使用别名发送电子邮件。 However, the same fails, if I use 1.4.7 version. 但是,如果我使用1.4.7版本,同样会失败。 I assume any version higher than 1.4 is not working. 我认为任何高于1.4的版本都不起作用。 Have anybody encountered the same? 有人遇到过同样的事情吗? Is there any security configuration added to later versions or any additional parameters that needs to be passed? 是否有任何安全配置添加到更高版本或需要传递的任何其他参数?

Session Debug logs when error occurred using JavaMail v1.4.7 as below: 使用JavaMail v1.4.7发生错误时的会话调试日志如下:

DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
DEBUG IMAP: mail.imap.fetchsize: 16384
DEBUG IMAP: mail.imap.ignorebodystructuresize: false
DEBUG IMAP: mail.imap.statuscachetimeout: 1000
DEBUG IMAP: mail.imap.appendbuffersize: -1
DEBUG IMAP: mail.imap.minidletime: 10
DEBUG IMAP: trying to connect to host "Exchange IP", port 143, isSSL false
* OK The Microsoft Exchange IMAP4 service is ready.
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN STARTTLS UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
A0 OK CAPABILITY completed.
DEBUG IMAP: AUTH: NTLM
DEBUG IMAP: AUTH: GSSAPI
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: protocolConnect login, host=Exchange IP, user=diffUser, password=<non-null>
DEBUG IMAP: AUTHENTICATE PLAIN command trace suppressed
DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 OK AUTHENTICATE completed.
A2 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN STARTTLS UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
A2 OK CAPABILITY completed.
DEBUG IMAP: AUTH: NTLM
DEBUG IMAP: AUTH: GSSAPI
DEBUG IMAP: AUTH: PLAIN
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "Exchange IP", port 25, isSSL false
220 EXC001-ABC.mycompany.org Microsoft ESMTP MAIL Service ready at Mon, 8 Jul 2019 16:49:59 +0100
DEBUG SMTP: connected to host "Exchange IP", port: 25

EHLO SCCM-10C.mycompany.org
250-EXC001-ABC.mycompany.org Hello [Machine IP]
250-SIZE 20971520
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH LOGIN
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "20971520"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN succeeded
DEBUG SMTP: use8bit false
MAIL FROM:<from@company.org>
250 2.1.0 Sender OK
RCPT TO:<to@diffcompany.org>
250 2.1.5 Recipient OK
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   to@diffcompany.org
DATA
354 Start mail input; end with <CRLF>.<CRLF>
From: from@company.org
To: to@diffcompany.org
Message-ID: <1308244637.0.1562600999518.JavaMail.Sam-adm@SCCM-10C>
Subject: This is the Subject Line!
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This is actual message
.
550 5.7.1 Client does not have permissions to send as this sender
DEBUG SMTP: got response code 550, with response: 550 5.7.1 Client does not have permissions to send as this sender

RSET
250 2.0.0 Resetting
DEBUG SMTP: MessagingException while sending, THROW: 
com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.1 Client does not have permissions to send as this sender

    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2108)
    at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1889)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1120)
    at javax.mail.Transport.send0(Transport.java:195)
    at javax.mail.Transport.send(Transport.java:124)
    at SendEmail.getExchangeStore(SendEmail.java:141)
    at SendEmail.main(SendEmail.java:14)
QUIT
221 2.0.0 Service closing transmission channel
com.sun.mail.smtp.SMTPSendFailedException: 550 5.7.1 Client does not have permissions to send as this sender

Debug Logs of working example with JavaMail v1.4 JavaMail v1.4的工作示例的调试日志

DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
* OK The Microsoft Exchange IMAP4 service is ready.
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN STARTTLS UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
A0 OK CAPABILITY completed.
IMAP DEBUG: AUTH: NTLM
IMAP DEBUG: AUTH: GSSAPI
IMAP DEBUG: AUTH: PLAIN
DEBUG: protocolConnect login, host=Exchange IP, user=diffUser, password=<non-null>
A1 AUTHENTICATE PLAIN
+
A1 OK AUTHENTICATE completed.
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "Exchange IP", port 25, isSSL false
220 EXC001-ABC.mycompany.org Microsoft ESMTP MAIL Service ready at Mon, 8 Jul 2019 16:55:59 +0100
DEBUG SMTP: connected to host "Exchange IP", port: 25

EHLO SCCM-10C.mycompany.org
250-EXC001-ABC.mycompany.org Hello [Machine IP]
250-SIZE 20971520
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH LOGIN
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "20971520"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<from@company.org>
250 2.1.0 Sender OK
RCPT TO:<to@diffcompany.org>
250 2.1.5 Recipient OK
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   to@diffcompany.org
DATA
354 Start mail input; end with <CRLF>.<CRLF>
From: from@company.org
To: to@diffcompany.org
Message-ID: <548246552.01562601360722.JavaMail.Sam-adm@SCCM-10C.mycompany.org>
Subject: This is the Subject Line!
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This is actual message
.
250 2.6.0 <548246552.01562601360722.JavaMail.Sam-adm@SCCM-10C.mycompany.org> [InternalId=344885] Queued mail for delivery
QUIT
221 2.0.0 Service closing transmission channel

When using JavaMail 1.4.7, you're authenticating to the SMTP server. 使用JavaMail 1.4.7时,您正在向SMTP服务器进行身份验证。 When using JavaMail 1.4, you're not authenticating. 使用JavaMail 1.4时,您无需进行身份验证。 Something about the way you're configuring authentication is causing different behavior. 关于您配置身份验证的方式引起了不同的行为。 Perhaps you're doing 也许你在做

props.setProperty("mail.smtp.auth", true);

instead of 代替

props.setProperty("mail.smtp.auth", "true");

In JavaMail 1.4, the first resulted in the property being set to false. 在JavaMail 1.4中,第一个导致该属性设置为false。 In JavaMail 1.4.7 it now handles both string and primitive objects as the value and sets the property to true. 在JavaMail 1.4.7中,它现在将字符串和原始对象都作为值处理,并将属性设置为true。

But I have no idea why your server rejects the message when you authenticate but accepts it when you're anonymous. 但是我不知道为什么您的服务器在进行身份验证时会拒绝该消息,而在您匿名时会接受它。

(Also, you need to change your password - the base64 encoded PLAIN authentication output includes your password.) (此外,您需要更改密码-base64编码的PLAIN身份验证输出包括您的密码。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM