This repository was archived by the owner on Dec 12, 2024. It is now read-only.
File tree 1 file changed +26
-1
lines changed
1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -1662,13 +1662,32 @@ class ForwardEmail {
1662
1662
// if no recipients return early with bounces joined together
1663
1663
if ( _ . isEmpty ( recipients ) ) {
1664
1664
if ( _ . isEmpty ( bounces ) ) throw new CustomError ( 'Invalid recipients' ) ;
1665
+ const codes = bounces . map ( ( bounce ) => {
1666
+ if ( _ . isNumber ( bounce . err . responseCode ) )
1667
+ return bounce . err . responseCode ;
1668
+ if (
1669
+ _ . isString ( bounce . err . code ) &&
1670
+ RETRY_CODES . includes ( bounce . err . code )
1671
+ )
1672
+ return CODES_TO_RESPONSE_CODES [ bounce . err . code ] ;
1673
+ if (
1674
+ ( bounce . err . code &&
1675
+ HTTP_RETRY_ERROR_CODES . has ( bounce . err . code ) ) ||
1676
+ ( _ . isNumber ( bounce . err . status ) &&
1677
+ HTTP_RETRY_STATUS_CODES . has ( bounce . err . status ) )
1678
+ )
1679
+ return 421 ;
1680
+ return 550 ;
1681
+ } ) ;
1682
+ const [ code ] = codes . sort ( ) ;
1665
1683
throw new CustomError (
1666
1684
bounces
1667
1685
. map (
1668
1686
( bounce ) =>
1669
1687
`Error for ${ bounce . address } of "${ bounce . err . message } "`
1670
1688
)
1671
- . join ( ', ' )
1689
+ . join ( ', ' ) ,
1690
+ code
1672
1691
) ;
1673
1692
}
1674
1693
@@ -1926,6 +1945,12 @@ class ForwardEmail {
1926
1945
RETRY_CODES . includes ( bounce . err . code )
1927
1946
)
1928
1947
return CODES_TO_RESPONSE_CODES [ bounce . err . code ] ;
1948
+ if (
1949
+ ( bounce . err . code && HTTP_RETRY_ERROR_CODES . has ( bounce . err . code ) ) ||
1950
+ ( _ . isNumber ( bounce . err . status ) &&
1951
+ HTTP_RETRY_STATUS_CODES . has ( bounce . err . status ) )
1952
+ )
1953
+ return 421 ;
1929
1954
return 550 ;
1930
1955
} ) ;
1931
1956
You can’t perform that action at this time.
0 commit comments