mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-25 18:43:08 +07:00
Merge pull request #6 from sturman/attachment
Add option to add attachments to mail message
This commit is contained in:
commit
0e3a58617a
@ -21,4 +21,6 @@ An action that simply sends a mail to multiple recipients.
|
||||
from: Luke Skywalker # <user@example.com>
|
||||
# Optional content type (defaults to text/plain):
|
||||
content_type: text/html
|
||||
# Optional attachments
|
||||
attachments: attachments.zip,git.diff,./dist/static/main.js
|
||||
```
|
||||
|
@ -33,6 +33,9 @@ inputs:
|
||||
description: Content-Type HTTP header (text/html or text/plain)
|
||||
required: false
|
||||
default: text/plain
|
||||
attachments:
|
||||
description: Files that will be added to mail message attachments (separated with comma)
|
||||
required: false
|
||||
runs:
|
||||
using: node12
|
||||
main: main.js
|
||||
|
2
main.js
2
main.js
@ -30,6 +30,7 @@ async function main() {
|
||||
const to = core.getInput("to", { required: true })
|
||||
const from = core.getInput("from", { required: true })
|
||||
const content_type = core.getInput("content_type", { required: true })
|
||||
const attachments = core.getInput("attachments", { required: false })
|
||||
|
||||
const transport = nodemailer.createTransport({
|
||||
host: server_address,
|
||||
@ -47,6 +48,7 @@ async function main() {
|
||||
subject: subject,
|
||||
text: content_type != "text/html" ? get_body(body) : undefined,
|
||||
html: content_type == "text/html" ? get_body(body) : undefined,
|
||||
attachments: attachments ? attachments.split(',').map(f => ({ path: f.trim() })) : undefined
|
||||
})
|
||||
|
||||
console.log(info)
|
||||
|
Loading…
Reference in New Issue
Block a user