@@ -37,6 +37,12 @@ async function getAttachments(attachments) {
3737return files . map ( f => ( { filename :path . basename ( f ) , path :f , cid :f . replace ( / ^ .* [ \\ \/ ] / , '' ) } ) )
3838}
3939
40+ function sleep ( ms ) {
41+ return new Promise ( ( resolve ) => {
42+ setTimeout ( resolve , ms ) ;
43+ } ) ;
44+ }
45+
4046async function main ( ) {
4147try {
4248let serverAddress = core . getInput ( "server_address" )
@@ -118,20 +124,43 @@ async function main() {
118124debug :nodemailerdebug ,
119125} )
120126
121- const info = await transport . sendMail ( {
122- from :getFrom ( from , username ) ,
123- to :to ,
124- subject :getText ( subject , false ) ,
125- cc :cc ?cc :undefined ,
126- bcc :bcc ?bcc :undefined ,
127- replyTo :replyTo ?replyTo :undefined ,
128- inReplyTo :inReplyTo ?inReplyTo :undefined ,
129- references :inReplyTo ?inReplyTo :undefined ,
130- text :body ?getText ( body , false ) :undefined ,
131- html :htmlBody ?getText ( htmlBody , convertMarkdown ) :undefined ,
132- priority :priority ?priority :undefined ,
133- attachments :attachments ?( await getAttachments ( attachments ) ) :undefined ,
134- } )
127+ var i = 1 ;
128+ while ( true ) {
129+ try {
130+ const info = await transport . sendMail ( {
131+ from :getFrom ( from , username ) ,
132+ to :to ,
133+ subject :getText ( subject , false ) ,
134+ cc :cc ?cc :undefined ,
135+ bcc :bcc ?bcc :undefined ,
136+ replyTo :replyTo ?replyTo :undefined ,
137+ inReplyTo :inReplyTo ?inReplyTo :undefined ,
138+ references :inReplyTo ?inReplyTo :undefined ,
139+ text :body ?getText ( body , false ) :undefined ,
140+ html :htmlBody ?getText ( htmlBody , convertMarkdown ) :undefined ,
141+ priority :priority ?priority :undefined ,
142+ attachments :attachments ?( await getAttachments ( attachments ) ) :undefined ,
143+ } ) ;
144+ break ;
145+ } catch ( error ) {
146+ if ( ! error . message . includes ( "Try again later," ) ) {
147+ core . setFailed ( error . message )
148+ break ;
149+ }
150+ if ( i > 10 ) {
151+ core . setFailed ( error . message )
152+ break ;
153+ }
154+ console . log ( "Received: " + error . message ) ;
155+ if ( i < 2 ) {
156+ console . log ( "Trying again in a minute..." ) ;
157+ } else {
158+ console . log ( "Trying again in " + i + " minutes..." ) ;
159+ }
160+ await sleep ( i * 60000 ) ;
161+ i ++ ;
162+ }
163+ }
135164} catch ( error ) {
136165core . setFailed ( error . message )
137166}