mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-11-10 05:51:07 +07:00
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
This commit is contained in:
parent
98b61f505d
commit
db36373cbe
@ -20,9 +20,9 @@ Some features:
|
|||||||
server_address: smtp.gmail.com
|
server_address: smtp.gmail.com
|
||||||
# Required mail server port:
|
# Required mail server port:
|
||||||
server_port: 465
|
server_port: 465
|
||||||
# Required mail server username:
|
# Optional (recommended): mail server username:
|
||||||
username: ${{secrets.MAIL_USERNAME}}
|
username: ${{secrets.MAIL_USERNAME}}
|
||||||
# Required mail server password:
|
# Optional (recommended) mail server password:
|
||||||
password: ${{secrets.MAIL_PASSWORD}}
|
password: ${{secrets.MAIL_PASSWORD}}
|
||||||
# Required mail subject:
|
# Required mail subject:
|
||||||
subject: Github Actions job result
|
subject: Github Actions job result
|
||||||
@ -62,3 +62,8 @@ Changes in Gmail settings may be necessary to get this action to work.
|
|||||||
3. If the Gmail account you're trying to use in this Action is already 2FA (Two Factor Authentication) enabled, the 2FA password will need to be provided as well, which isn't included in the default template.
|
3. If the Gmail account you're trying to use in this Action is already 2FA (Two Factor Authentication) enabled, the 2FA password will need to be provided as well, which isn't included in the default template.
|
||||||
|
|
||||||
Users who have had problems have reported success by doing each of these three steps or by doing the first two steps and using a Gmail account that didn't have 2FA enabled.
|
Users who have had problems have reported success by doing each of these three steps or by doing the first two steps and using a Gmail account that didn't have 2FA enabled.
|
||||||
|
|
||||||
|
### Unauthenticated login (username/password fields)
|
||||||
|
|
||||||
|
The parameters `username` and `password` are set as optional to support self-hosted runners access to on-premise infrastructure. If
|
||||||
|
you are accessing public email servers make sure you provide a username/password authentication through [GitHub Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) to make the email delivery secure.
|
||||||
|
@ -13,10 +13,10 @@ inputs:
|
|||||||
required: true
|
required: true
|
||||||
username:
|
username:
|
||||||
description: Authenticate as this user to SMTP server
|
description: Authenticate as this user to SMTP server
|
||||||
required: true
|
required: false
|
||||||
password:
|
password:
|
||||||
description: Authenticate with this password to SMTP server
|
description: Authenticate with this password to SMTP server
|
||||||
required: true
|
required: false
|
||||||
subject:
|
subject:
|
||||||
description: Subject of mail message
|
description: Subject of mail message
|
||||||
required: true
|
required: true
|
||||||
|
22
main.js
22
main.js
@ -33,8 +33,8 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
const serverAddress = core.getInput("server_address", { required: true })
|
const serverAddress = core.getInput("server_address", { required: true })
|
||||||
const serverPort = core.getInput("server_port", { required: true })
|
const serverPort = core.getInput("server_port", { required: true })
|
||||||
const username = core.getInput("username", { required: true })
|
const username = core.getInput("username")
|
||||||
const password = core.getInput("password", { required: true })
|
const password = core.getInput("password")
|
||||||
const subject = core.getInput("subject", { required: true })
|
const subject = core.getInput("subject", { required: true })
|
||||||
const from = core.getInput("from", { required: true })
|
const from = core.getInput("from", { required: true })
|
||||||
const to = core.getInput("to", { required: true })
|
const to = core.getInput("to", { required: true })
|
||||||
@ -48,17 +48,21 @@ async function main() {
|
|||||||
const convertMarkdown = core.getInput("convert_markdown", { required: false })
|
const convertMarkdown = core.getInput("convert_markdown", { required: false })
|
||||||
const ignoreCert = core.getInput("ignore_cert", { required: false })
|
const ignoreCert = core.getInput("ignore_cert", { required: false })
|
||||||
|
|
||||||
|
if (!username || !password) {
|
||||||
|
core.warning("Username and password not specified. You should only do this if you are using a self-hosted runner to access an on-premise mail server.")
|
||||||
|
}
|
||||||
|
|
||||||
const transport = nodemailer.createTransport({
|
const transport = nodemailer.createTransport({
|
||||||
host: serverAddress,
|
host: serverAddress,
|
||||||
port: serverPort,
|
auth: username && password ? {
|
||||||
secure: secure ? true : serverPort == "465",
|
|
||||||
auth: {
|
|
||||||
user: username,
|
user: username,
|
||||||
pass: password,
|
pass: password
|
||||||
},
|
} : undefined,
|
||||||
tls: ignoreCert ? {
|
port: serverPort,
|
||||||
|
secure: secure == "true" ? true : serverPort == "465",
|
||||||
|
tls: ignoreCert == "true" ? {
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
} : undefined
|
} : undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
const info = await transport.sendMail({
|
const info = await transport.sendMail({
|
||||||
|
15
package.json
15
package.json
@ -1,21 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "action-send-mail",
|
"name": "action-send-mail",
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "An action that simply sends a mail to multiple recipients.",
|
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/dawidd6/action-send-mail.git"
|
|
||||||
},
|
|
||||||
"author": "dawidd6",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/dawidd6/action-send-mail/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/dawidd6/action-send-mail#readme",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.7",
|
"@actions/core": "^1.2.7",
|
||||||
"nodemailer": "^6.4.17",
|
"nodemailer": "^6.4.17",
|
||||||
|
Loading…
Reference in New Issue
Block a user