Java Mail SendFailedException 501提供的RCPT TO地址无效

时间:2018-04-12 18:10:00

标签: java email javamail amazon-ses

在我们的生产服务器上遇到此错误(当然,测试服务器上仍有问题)但电子邮件已停止发送。

Email error: Invalid Addresses
javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 501 Invalid RCPT TO address provided

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1862)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1118)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)

我在一些常用代码中添加了一些调试:

MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(fromEmail)); InternetAddress[] toAddrs = InternetAddress.parse(email); System.out.println("Setting TO Recipient to " + email); for( InternetAddress ia : toAddrs ){ System.out.println(" InternetAddress: " + ia.toString()); } message.setRecipients(Message.RecipientType.TO, toAddrs); ... ... Transport.send(message); } catch (SendFailedException sfe) { Address[] invalidAddrs = sfe.getInvalidAddresses(); System.out.println("[EmailHelper] SendFailedException: " + sfe.getMessage() + " -- " + InternetAddress.toString(sfe.getInvalidAddresses())); System.out.println("-- end SendFailedInspection\n"); }

我看到的输出令人费解(电子邮件地址已更改):

Setting TO Recipient to clay@clay.com InternetAddress: clay@clay.com [EmailHelper] SendFailedException: Invalid Addresses -- apple -- end SendFailedInspection

我的意思是,字面意思是“苹果”!

我在MacOX上构建JAR并部署到Amazon Linux。这是“苹果”的来源吗?我将SMTP消息发送到AWS Simple Email Service(在我们的其他服务上可以正常工作)。

此代码已经工作了几个月,但它似乎在一夜之间发生了变化(可能与yum update有关。)

无论如何,如果你有任何想法,这很奇怪。谢谢!

编辑 JavaMail调试信息(个人资料编辑):

04/12/2018 14:12:59 : 571449 Send Note with Reports to clay@clay.com Failed DEBUG: setDebug: JavaMail version 1.5.0 Setting TO Recipient to clay@clay.com InternetAddress: clay@clay.com 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 "email-host-aws.com", port 25, isSSL false 220 email-smtp.amazonaws.com ESMTP SimpleEmailService-2762711029 LtFXRutjiksFKUW DEBUG SMTP: connected to host "email-host-aws.com", port: 465 EHLO ip-172-31-58-4.ec2.internal 250-email-smtp.amazonaws.com 250-8BITMIME 250-SIZE 10485760 250-AUTH PLAIN LOGIN 250 Ok DEBUG SMTP: Found extension "8BITMIME", arg "" DEBUG SMTP: Found extension "SIZE", arg "10485760" DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN" DEBUG SMTP: Found extension "Ok", 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:<clay@clay.com> 250 Ok RCPT TO:<clay@clay.com> 250 Ok RCPT TO:<apple> 501 Invalid RCPT TO address provided DEBUG SMTP: Valid Unsent Addresses DEBUG SMTP: clay@clay.com DEBUG SMTP: Invalid Addresses DEBUG SMTP: apple DEBUG SMTP: Sending failed because of invalid destination addresses RSET 250 Ok DEBUG SMTP: MessagingException while sending, THROW: javax.mail.SendFailedException: Invalid Addresses; nested exception is: com.sun.mail.smtp.SMTPAddressFailedException: 501 Invalid RCPT TO address provided at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1862) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1118) at javax.mail.Transport.send0(Transport.java:254) at javax.mail.Transport.send(Transport.java:124) ... Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 501 Invalid RCPT TO address provided at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1715) ... 7 more QUIT 221 Bye

“RCPT TO:”来自哪里?这是什么?

0 个答案:

没有答案