mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-26 11:03:06 +07:00
support multipart email (#48)
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
This commit is contained in:
parent
32390e9a18
commit
c938b3cb85
31
README.md
31
README.md
@ -8,27 +8,32 @@ An action that simply sends a mail to multiple recipients.
|
|||||||
- name: Send mail
|
- name: Send mail
|
||||||
uses: dawidd6/action-send-mail@v2
|
uses: dawidd6/action-send-mail@v2
|
||||||
with:
|
with:
|
||||||
|
# Required mail server address:
|
||||||
server_address: smtp.gmail.com
|
server_address: smtp.gmail.com
|
||||||
|
# Required mail server port:
|
||||||
server_port: 465
|
server_port: 465
|
||||||
|
# Required mail server username:
|
||||||
username: ${{secrets.MAIL_USERNAME}}
|
username: ${{secrets.MAIL_USERNAME}}
|
||||||
|
# Required mail server password:
|
||||||
password: ${{secrets.MAIL_PASSWORD}}
|
password: ${{secrets.MAIL_PASSWORD}}
|
||||||
|
# Required mail subject:
|
||||||
subject: Github Actions job result
|
subject: Github Actions job result
|
||||||
# Literal body:
|
# Required recipients' addresses:
|
||||||
body: Build job of ${{github.repository}} completed successfully!
|
|
||||||
# Read file contents as body:
|
|
||||||
body: file://README.md
|
|
||||||
to: obiwan@example.com,yoda@example.com
|
to: obiwan@example.com,yoda@example.com
|
||||||
|
# Required sender information (address can be skipped):
|
||||||
from: Luke Skywalker # <user@example.com>
|
from: Luke Skywalker # <user@example.com>
|
||||||
# Optional carbon copy recipients
|
# Optional plain body:
|
||||||
|
body: Build job of ${{github.repository}} completed successfully!
|
||||||
|
# Optional HTML body read from file:
|
||||||
|
html_body: file://README.html
|
||||||
|
# Optional carbon copy recipients:
|
||||||
cc: kyloren@example.com,leia@example.com
|
cc: kyloren@example.com,leia@example.com
|
||||||
# Optional blind carbon copy recipients
|
# Optional blind carbon copy recipients:
|
||||||
bcc: r2d2@example.com,hansolo@example.com
|
bcc: r2d2@example.com,hansolo@example.com
|
||||||
# Optional recipient of the email response
|
# Optional recipient of the email response:
|
||||||
reply_to: luke@example.com
|
reply_to: luke@example.com
|
||||||
# Optional unsigned/invalid certificates allowance:
|
# Optional unsigned/invalid certificates allowance:
|
||||||
ignore_cert: true
|
ignore_cert: true
|
||||||
# Optional content type (defaults to text/plain):
|
|
||||||
content_type: text/html
|
|
||||||
# Optional converting Markdown to HTML (set content_type to text/html too):
|
# Optional converting Markdown to HTML (set content_type to text/html too):
|
||||||
convert_markdown: true
|
convert_markdown: true
|
||||||
# Optional attachments:
|
# Optional attachments:
|
||||||
@ -39,11 +44,11 @@ An action that simply sends a mail to multiple recipients.
|
|||||||
|
|
||||||
### Gmail
|
### Gmail
|
||||||
|
|
||||||
Gmail security settings may cause this Action to fail. This failure may involve a message in the GitHub Actions details about access being denied and an email from Google to the email account being used about a sign-in being blocked and why.
|
Gmail security settings may cause this Action to fail. This failure may involve a message in the GitHub Actions details about access being denied and an email from Google to the email account being used about a sign-in being blocked and why.
|
||||||
|
|
||||||
Changes in Gmail settings may be necessary to get this action to work.
|
Changes in Gmail settings may be necessary to get this action to work.
|
||||||
1. Google treats this method of using email as a "Less Secure App". However, "Less Secure Apps" can be enabled in Google profile settings. There doesn't appear to be a static link for this, but if you go to Google profile settings while signed-in and type "less secure apps" into the search bar, the appropriate instructions will come up.
|
1. Google treats this method of using email as a "Less Secure App". However, "Less Secure Apps" can be enabled in Google profile settings. There doesn't appear to be a static link for this, but if you go to Google profile settings while signed-in and type "less secure apps" into the search bar, the appropriate instructions will come up.
|
||||||
2. IMAP needs to be enabled in Gmail settings as described here: https://support.google.com/mail/answer/7126229?hl=en
|
2. IMAP needs to be enabled in Gmail settings as described here: https://support.google.com/mail/answer/7126229?hl=en
|
||||||
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.
|
||||||
|
13
action.yml
13
action.yml
@ -20,15 +20,18 @@ inputs:
|
|||||||
subject:
|
subject:
|
||||||
description: Subject of mail message
|
description: Subject of mail message
|
||||||
required: true
|
required: true
|
||||||
body:
|
|
||||||
description: Body of mail message (might be a filename prefixed with file:// to read from)
|
|
||||||
required: true
|
|
||||||
to:
|
to:
|
||||||
description: Recipients mail addresses (separated with comma)
|
description: Recipients mail addresses (separated with comma)
|
||||||
required: true
|
required: true
|
||||||
from:
|
from:
|
||||||
description: Full name of mail sender (might be with an email address specified in <>)
|
description: Full name of mail sender (might be with an email address specified in <>)
|
||||||
required: true
|
required: true
|
||||||
|
body:
|
||||||
|
description: Body of mail message (might be a filename prefixed with file:// to read from)
|
||||||
|
required: false
|
||||||
|
html_body:
|
||||||
|
description: HTML body of mail message (might be a filename prefixed with file:// to read from)
|
||||||
|
required: false
|
||||||
cc:
|
cc:
|
||||||
description: Carbon copy recipients (separated with comma)
|
description: Carbon copy recipients (separated with comma)
|
||||||
required: false
|
required: false
|
||||||
@ -41,10 +44,6 @@ inputs:
|
|||||||
ignore_cert:
|
ignore_cert:
|
||||||
description: Allow unsigned/invalid certificates
|
description: Allow unsigned/invalid certificates
|
||||||
required: false
|
required: false
|
||||||
content_type:
|
|
||||||
description: Content-Type HTTP header (text/html or text/plain)
|
|
||||||
required: false
|
|
||||||
default: text/plain
|
|
||||||
convert_markdown:
|
convert_markdown:
|
||||||
description: Convert body from Markdown to HTML (set content_type input as text/html too)
|
description: Convert body from Markdown to HTML (set content_type input as text/html too)
|
||||||
required: false
|
required: false
|
||||||
|
12
main.js
12
main.js
@ -36,13 +36,13 @@ async function main() {
|
|||||||
const username = core.getInput("username", { required: true })
|
const username = core.getInput("username", { required: true })
|
||||||
const password = core.getInput("password", { required: true })
|
const password = core.getInput("password", { required: true })
|
||||||
const subject = core.getInput("subject", { required: true })
|
const subject = core.getInput("subject", { required: true })
|
||||||
const body = core.getInput("body", { 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 })
|
||||||
|
const body = core.getInput("body", { required: false })
|
||||||
|
const htmlBody = core.getInput("html_body", { required: false })
|
||||||
const cc = core.getInput("cc", { required: false })
|
const cc = core.getInput("cc", { required: false })
|
||||||
const bcc = core.getInput("bcc", { required: false })
|
const bcc = core.getInput("bcc", { required: false })
|
||||||
const replyTo = core.getInput("reply_to", { required: false })
|
const replyTo = core.getInput("reply_to", { required: false })
|
||||||
const contentType = core.getInput("content_type", { required: true })
|
|
||||||
const attachments = core.getInput("attachments", { required: false })
|
const attachments = core.getInput("attachments", { required: false })
|
||||||
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 })
|
||||||
@ -59,16 +59,16 @@ async function main() {
|
|||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
} : undefined
|
} : undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
const info = await transport.sendMail({
|
const info = await transport.sendMail({
|
||||||
from: getFrom(from, username),
|
from: getFrom(from, username),
|
||||||
to: to,
|
to: to,
|
||||||
|
subject: subject,
|
||||||
cc: cc ? cc : undefined,
|
cc: cc ? cc : undefined,
|
||||||
bcc: bcc ? bcc : undefined,
|
bcc: bcc ? bcc : undefined,
|
||||||
replyTo: replyTo ? replyTo : undefined,
|
replyTo: replyTo ? replyTo : undefined,
|
||||||
subject: subject,
|
text: body ? getBody(body, convertMarkdown) : undefined,
|
||||||
text: contentType != "text/html" ? getBody(body, convertMarkdown) : undefined,
|
html: htmlBody ? getBody(htmlBody, convertMarkdown) : undefined,
|
||||||
html: contentType == "text/html" ? getBody(body, convertMarkdown) : undefined,
|
|
||||||
attachments: attachments ? attachments.split(',').map(f => ({ path: f.trim() })) : undefined
|
attachments: attachments ? attachments.split(',').map(f => ({ path: f.trim() })) : undefined
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user