mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-25 18:43:08 +07:00
parent
eaa39a13cd
commit
2afa768d34
57
main.js
57
main.js
@ -37,6 +37,12 @@ async function getAttachments(attachments) {
|
|||||||
return files.map(f => ({ filename: path.basename(f), path: f, cid: f.replace(/^.*[\\\/]/, '')}))
|
return files.map(f => ({ filename: path.basename(f), path: f, cid: f.replace(/^.*[\\\/]/, '')}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sleep(ms) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, ms);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
let serverAddress = core.getInput("server_address")
|
let serverAddress = core.getInput("server_address")
|
||||||
@ -118,20 +124,43 @@ async function main() {
|
|||||||
debug: nodemailerdebug,
|
debug: nodemailerdebug,
|
||||||
})
|
})
|
||||||
|
|
||||||
const info = await transport.sendMail({
|
var i = 1;
|
||||||
from: getFrom(from, username),
|
while (true) {
|
||||||
to: to,
|
try {
|
||||||
subject: getText(subject, false),
|
const info = await transport.sendMail({
|
||||||
cc: cc ? cc : undefined,
|
from: getFrom(from, username),
|
||||||
bcc: bcc ? bcc : undefined,
|
to: to,
|
||||||
replyTo: replyTo ? replyTo : undefined,
|
subject: getText(subject, false),
|
||||||
inReplyTo: inReplyTo ? inReplyTo : undefined,
|
cc: cc ? cc : undefined,
|
||||||
references: inReplyTo ? inReplyTo : undefined,
|
bcc: bcc ? bcc : undefined,
|
||||||
text: body ? getText(body, false) : undefined,
|
replyTo: replyTo ? replyTo : undefined,
|
||||||
html: htmlBody ? getText(htmlBody, convertMarkdown) : undefined,
|
inReplyTo: inReplyTo ? inReplyTo : undefined,
|
||||||
priority: priority ? priority : undefined,
|
references: inReplyTo ? inReplyTo : undefined,
|
||||||
attachments: attachments ? (await getAttachments(attachments)) : undefined,
|
text: body ? getText(body, false) : undefined,
|
||||||
})
|
html: htmlBody ? getText(htmlBody, convertMarkdown) : undefined,
|
||||||
|
priority: priority ? priority : undefined,
|
||||||
|
attachments: attachments ? (await getAttachments(attachments)) : undefined,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
} catch (error) {
|
||||||
|
if (!error.message.includes("Try again later,")) {
|
||||||
|
core.setFailed(error.message)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i > 10) {
|
||||||
|
core.setFailed(error.message)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
console.log("Received: " + error.message);
|
||||||
|
if (i < 2) {
|
||||||
|
console.log("Trying again in a minute...");
|
||||||
|
} else {
|
||||||
|
console.log("Trying again in " + i + " minutes...");
|
||||||
|
}
|
||||||
|
await sleep(i * 60000);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user