mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-26 19:13:06 +07:00
support multipart email (#48)
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
This commit is contained in:
parent
32390e9a18
commit
c938b3cb85
23
README.md
23
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:
|
||||||
|
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
|
||||||
|
10
main.js
10
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 })
|
||||||
@ -63,12 +63,12 @@ async function main() {
|
|||||||
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