send-mail/README.md

72 lines
3.1 KiB
Markdown
Raw Normal View History

2019-11-18 19:23:22 +07:00
# Send mail Github Action
2019-11-18 19:05:04 +07:00
2019-11-18 19:23:22 +07:00
An action that simply sends a mail to multiple recipients.
2019-11-18 19:05:04 +07:00
2021-04-25 21:45:57 +07:00
Some features:
- plain text body
- HTML body
- multipart body (plain text + HTML)
- Markdown to HTML converting
2021-07-13 23:23:48 +07:00
- file attachments (supports globbing)
2021-04-25 21:45:57 +07:00
2019-11-18 19:23:22 +07:00
## Usage
```yaml
- name: Send mail
2021-04-25 21:45:57 +07:00
uses: dawidd6/action-send-mail@v3
2019-11-18 19:23:22 +07:00
with:
# Required mail server address:
2019-11-18 19:23:22 +07:00
server_address: smtp.gmail.com
# Required mail server port:
2019-11-18 19:23:22 +07:00
server_port: 465
# Optional (recommended): mail server username:
2019-11-18 19:23:22 +07:00
username: ${{secrets.MAIL_USERNAME}}
# Optional (recommended) mail server password:
2019-11-18 19:23:22 +07:00
password: ${{secrets.MAIL_PASSWORD}}
# Required mail subject:
2019-11-18 19:23:22 +07:00
subject: Github Actions job result
# Required recipients' addresses:
2021-02-23 04:16:12 +07:00
to: obiwan@example.com,yoda@example.com
2021-04-25 21:30:16 +07:00
# Required sender full name (address can be skipped):
2020-03-25 22:30:22 +07:00
from: Luke Skywalker # <user@example.com>
# Optional whether this connection use TLS (default is true if server_port is 465)
secure: true
# 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:
2021-02-23 04:16:12 +07:00
cc: kyloren@example.com,leia@example.com
# Optional blind carbon copy recipients:
2021-02-23 04:16:12 +07:00
bcc: r2d2@example.com,hansolo@example.com
# Optional recipient of the email response:
reply_to: luke@example.com
2021-04-02 05:02:58 +07:00
# Optional unsigned/invalid certificates allowance:
ignore_cert: true
# Optional converting Markdown to HTML (set content_type to text/html too):
convert_markdown: true
2020-04-07 15:36:16 +07:00
# Optional attachments:
2021-07-13 23:23:48 +07:00
attachments: attachments.zip,git.diff,./dist/static/*.js
# Optional priority: 'high', 'normal' (default) or 'low'
priority: low
2019-11-18 19:23:22 +07:00
```
## Troubleshooting
### 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.
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](https://myaccount.google.com/lesssecureapps).
2021-04-25 21:43:10 +07:00
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.
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.
### Unauthenticated login (username/password fields)
The parameters `username` and `password` are set as optional to support self-hosted runners access to on-premise infrastructure. If
you are accessing public email servers make sure you provide a username/password authentication through [GitHub Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) to make the email delivery secure.