Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"invalid addresses" exception too broad #160

Open
Lonzak opened this issue Dec 16, 2024 · 3 comments
Open

"invalid addresses" exception too broad #160

Lonzak opened this issue Dec 16, 2024 · 3 comments

Comments

@Lonzak
Copy link

Lonzak commented Dec 16, 2024

I recently got lots of error messages from jakarta/angus mail: Invalid addresses but on further inspection (most of) the addresses were correct and valid. I had to dig through a lot of exception causes until I got to the real issue(s). Those were for example:

'Invalid Addresses' (3x caused by later): 471 4.7.1 <[email protected]>: The limits for your account are exceeded. Please try again later.
'Invalid Addresses' (3x caused by later): 550 5.4.4 Unable to relay
'Invalid Addresses' (3x caused by later): 500 5.0.0 Syntax error, command unrecognized
'Invalid Addresses' (3x caused by later): 555-5.5.2 Syntax error, cannot decode response. For more information, go to 555-5.5.2  https://support.google.com/a/answer/3221692 and review RFC 5321 555 5.5.2 specifications. 
'Invalid Addresses' (3x caused by later): 554 5.7.1 Client host rejected: Access denied

It seems that "invalid addresses" is some kind of default or fallback error message, which is however incorrect in certain (many?) cases.
Would it be possible to use a different error message like Error sending mail in case no clear or an unknown error code is used.
Ideally (optionally) the cause from the server would be great:

"Error sending email. The server reply was: '471 4.7.1 The limits for your account are exceeded.' "

@Lonzak Lonzak changed the title "invalid addresses" thrown eventoo broad "invalid addresses" exception too broad Dec 16, 2024
@jmehrens
Copy link
Contributor

That log looks like the debug log. What is the full Java stacktrace with exception names?

@Lonzak
Copy link
Author

Lonzak commented Dec 20, 2024

It is not a debug log since a real exception during mail sending is thrown...

 -  skipped unrelated parts of the stack trace -
Caused by: javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
	com.sun.mail.smtp.SMTPAddressFailedException: 471 4.7.1 <[email protected]>: Recipient address rejected: Rejected: The limits for your account are exceeded. Please try again later.

	at [email protected]//com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:2064)
	at [email protected]//com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1286)
	at deployment.ear//...
	... 170 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 471 4.7.1 <[email protected]>: Recipient address rejected: Rejected: The limits for your account are exceeded. Please try again later.

	at [email protected]//com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1964)
	... 172 more

I know it is still the javax version of mail since we just recently upgraded to angus mail (but not productive yet)

@jmehrens
Copy link
Contributor

Ok that helps. The source of the behavior is in the SMTPSendFailedException API docs:

This exception is thrown when the message cannot be sent.
This exception will usually appear first in a chained list of exceptions, followed by SMTPAddressFailedExceptions and/or SMTPAddressSucceededExceptions, * one per address. This exception corresponds to one of the SMTP commands used to send a message, such as the MAIL, DATA, and "end of data" commands, but not including the RCPT command.

We just need to dig into the logic to see if it was incorrectly was added to invalid list instead of the unsent list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants