mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2025-08-09 23:24:39 +07:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
2cea9617b0 | |||
3c36016689 | |||
b623fcf123 | |||
2afa768d34 | |||
eaa39a13cd | |||
4226df7daa | |||
97a10a20cc | |||
9767c2af4d | |||
d6910da162 |
@ -1,4 +1,4 @@
|
|||||||
# Send mail Github Action
|
# Send mail GitHub Action
|
||||||
|
|
||||||
An action that simply sends a mail to multiple recipients.
|
An action that simply sends a mail to multiple recipients.
|
||||||
|
|
||||||
|
@ -64,5 +64,5 @@ inputs:
|
|||||||
description: Debug option for nodemailer
|
description: Debug option for nodemailer
|
||||||
required: false
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: node16
|
using: node20
|
||||||
main: main.js
|
main: main.js
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
28
package-lock.json
generated
28
package-lock.json
generated
@ -6,16 +6,16 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "action-send-mail",
|
"name": "action-send-mail",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.7",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/glob": "^0.4.0",
|
"@actions/glob": "^0.4.0",
|
||||||
"nodemailer": "^6.9.1",
|
"nodemailer": "^6.9.13",
|
||||||
"showdown": "^1.9.1"
|
"showdown": "^1.9.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.10.0",
|
"version": "1.10.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
|
||||||
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
@ -171,9 +171,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemailer": {
|
"node_modules/nodemailer": {
|
||||||
"version": "6.9.1",
|
"version": "6.9.13",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.13.tgz",
|
||||||
"integrity": "sha512-qHw7dOiU5UKNnQpXktdgQ1d3OFgRAekuvbJLcdG5dnEo/GtcTHRYM7+UfJARdOFU9WUQO8OiIamgWPmiSFHYAA==",
|
"integrity": "sha512-7o38Yogx6krdoBf3jCAqnIN4oSQFx+fMa0I7dK1D+me9kBxx12D+/33wSb+fhOCtIxvYJ+4x4IMEhmhCKfAiOA==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
}
|
}
|
||||||
@ -341,9 +341,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.10.0",
|
"version": "1.10.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
|
||||||
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
@ -472,9 +472,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nodemailer": {
|
"nodemailer": {
|
||||||
"version": "6.9.1",
|
"version": "6.9.13",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.13.tgz",
|
||||||
"integrity": "sha512-qHw7dOiU5UKNnQpXktdgQ1d3OFgRAekuvbJLcdG5dnEo/GtcTHRYM7+UfJARdOFU9WUQO8OiIamgWPmiSFHYAA=="
|
"integrity": "sha512-7o38Yogx6krdoBf3jCAqnIN4oSQFx+fMa0I7dK1D+me9kBxx12D+/33wSb+fhOCtIxvYJ+4x4IMEhmhCKfAiOA=="
|
||||||
},
|
},
|
||||||
"p-limit": {
|
"p-limit": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
"name": "action-send-mail",
|
"name": "action-send-mail",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.7",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/glob": "^0.4.0",
|
"@actions/glob": "^0.4.0",
|
||||||
"nodemailer": "^6.9.1",
|
"nodemailer": "^6.9.13",
|
||||||
"showdown": "^1.9.1"
|
"showdown": "^1.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user