mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2025-07-01 12:43:15 +07:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
c6d4807c13 | |||
4586381ad5 | |||
b961a9185a | |||
ac180b7bd9 | |||
56a64662b4 | |||
296e585baf | |||
1cf295c810 | |||
f00590fc1a | |||
b27f0d4766 | |||
a4a1b1f1d5 | |||
ce64ae4df1 | |||
5b4b61f0c4 |
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
@ -6,6 +6,7 @@ jobs:
|
|||||||
main:
|
main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
|
max-parallel: 1
|
||||||
matrix:
|
matrix:
|
||||||
content_type:
|
content_type:
|
||||||
- text/plain
|
- text/plain
|
||||||
@ -23,7 +24,7 @@ jobs:
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout code
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
- name: Send mail
|
- name: Send mail
|
||||||
uses: ./
|
uses: ./
|
||||||
@ -34,6 +35,6 @@ jobs:
|
|||||||
password: ${{secrets.PASSWORD}}
|
password: ${{secrets.PASSWORD}}
|
||||||
subject: ${{github.repository}}
|
subject: ${{github.repository}}
|
||||||
body: ${{matrix.body}}
|
body: ${{matrix.body}}
|
||||||
to: ${{github.event.pusher.email}},${{secrets.USERNAME}}
|
to: ${{github.event.pusher.email}}
|
||||||
from: github-actions
|
from: github-actions
|
||||||
content_type: ${{matrix.content_type}}
|
content_type: ${{matrix.content_type}}
|
||||||
|
@ -18,7 +18,7 @@ An action that simply sends a mail to multiple recipients.
|
|||||||
# Read file contents as body:
|
# Read file contents as body:
|
||||||
body: file://README.md
|
body: file://README.md
|
||||||
to: obiwan@tatooine.com,yoda@dagobah.com
|
to: obiwan@tatooine.com,yoda@dagobah.com
|
||||||
from: Luke Skywalker
|
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
|
||||||
```
|
```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: Send email
|
name: Send email
|
||||||
description: Send mail to multiple recipients
|
description: Send an email to multiple recipients
|
||||||
author: dawidd6
|
author: dawidd6
|
||||||
branding:
|
branding:
|
||||||
icon: mail
|
icon: mail
|
||||||
@ -21,13 +21,13 @@ inputs:
|
|||||||
description: Subject of mail message
|
description: Subject of mail message
|
||||||
required: true
|
required: true
|
||||||
body:
|
body:
|
||||||
description: Body of mail message (might be a filename to read from)
|
description: Body of mail message (might be a filename prefixed with file:// to read from)
|
||||||
required: true
|
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
|
description: Full name of mail sender (might be with an email address specified in <>)
|
||||||
required: true
|
required: true
|
||||||
content_type:
|
content_type:
|
||||||
description: Content-Type HTTP header (text/html or text/plain)
|
description: Content-Type HTTP header (text/html or text/plain)
|
||||||
|
12
main.js
12
main.js
@ -11,6 +11,14 @@ function get_body(body) {
|
|||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_from(from, username) {
|
||||||
|
if (from.match(/.+<.+@.+>/)) {
|
||||||
|
return from
|
||||||
|
}
|
||||||
|
|
||||||
|
return `"${from}" <${username}>`
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
const server_address = core.getInput("server_address", { required: true })
|
const server_address = core.getInput("server_address", { required: true })
|
||||||
@ -34,7 +42,7 @@ async function main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const info = await transport.sendMail({
|
const info = await transport.sendMail({
|
||||||
from: `"${from}" <${username}>`,
|
from: get_from(from, username),
|
||||||
to: to,
|
to: to,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
text: content_type != "text/html" ? get_body(body) : undefined,
|
text: content_type != "text/html" ? get_body(body) : undefined,
|
||||||
@ -47,4 +55,4 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Reference in New Issue
Block a user