mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2025-07-05 06:33:15 +07:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
c550a7182d | |||
b75f3336d9 | |||
0e3a58617a | |||
3eb5d684cd | |||
02fea7e898 | |||
c2ca628a67 | |||
1733012f4d | |||
a5cba0b6c1 | |||
d4b4fe8144 | |||
67e2095a53 |
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -14,6 +14,7 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- content_type: text/plain
|
- content_type: text/plain
|
||||||
body: file://README.md
|
body: file://README.md
|
||||||
|
attachments: action.yml
|
||||||
- content_type: text/html
|
- content_type: text/html
|
||||||
body: |
|
body: |
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -23,6 +24,7 @@ jobs:
|
|||||||
<p>Paragraph</p>
|
<p>Paragraph</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
attachments: package.json,package-lock.json
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
@ -38,3 +40,4 @@ jobs:
|
|||||||
to: ${{github.event.pusher.email}}
|
to: ${{github.event.pusher.email}}
|
||||||
from: github-actions
|
from: github-actions
|
||||||
content_type: ${{matrix.content_type}}
|
content_type: ${{matrix.content_type}}
|
||||||
|
attachments: ${{matrix.attachments}}
|
||||||
|
@ -6,7 +6,7 @@ An action that simply sends a mail to multiple recipients.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Send mail
|
- name: Send mail
|
||||||
uses: dawidd6/action-send-mail@master
|
uses: dawidd6/action-send-mail@v2
|
||||||
with:
|
with:
|
||||||
server_address: smtp.gmail.com
|
server_address: smtp.gmail.com
|
||||||
server_port: 465
|
server_port: 465
|
||||||
@ -21,4 +21,6 @@ An action that simply sends a mail to multiple recipients.
|
|||||||
from: Luke Skywalker # <user@example.com>
|
from: Luke Skywalker # <user@example.com>
|
||||||
# Optional content type (defaults to text/plain):
|
# Optional content type (defaults to text/plain):
|
||||||
content_type: text/html
|
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)
|
description: Content-Type HTTP header (text/html or text/plain)
|
||||||
required: false
|
required: false
|
||||||
default: text/plain
|
default: text/plain
|
||||||
|
attachments:
|
||||||
|
description: Files that will be added to mail message attachments (separated with comma)
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: node12
|
using: node12
|
||||||
main: main.js
|
main: main.js
|
||||||
|
2
main.js
2
main.js
@ -30,6 +30,7 @@ async function main() {
|
|||||||
const to = core.getInput("to", { required: true })
|
const to = core.getInput("to", { required: true })
|
||||||
const from = core.getInput("from", { required: true })
|
const from = core.getInput("from", { required: true })
|
||||||
const content_type = core.getInput("content_type", { required: true })
|
const content_type = core.getInput("content_type", { required: true })
|
||||||
|
const attachments = core.getInput("attachments", { required: false })
|
||||||
|
|
||||||
const transport = nodemailer.createTransport({
|
const transport = nodemailer.createTransport({
|
||||||
host: server_address,
|
host: server_address,
|
||||||
@ -47,6 +48,7 @@ async function main() {
|
|||||||
subject: subject,
|
subject: subject,
|
||||||
text: content_type != "text/html" ? get_body(body) : undefined,
|
text: content_type != "text/html" ? get_body(body) : undefined,
|
||||||
html: 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)
|
console.log(info)
|
||||||
|
Reference in New Issue
Block a user