2024-01-06 13:49:07 +01:00
# Send mail GitHub Action
2019-11-18 13:05:04 +01:00
2019-11-18 13:23:22 +01:00
An action that simply sends a mail to multiple recipients.
2019-11-18 13:05:04 +01:00
2021-04-25 16:45:57 +02:00
Some features:
2025-06-14 23:10:25 +02:00
2021-04-25 16:45:57 +02:00
- plain text body
- HTML body
- multipart body (plain text + HTML)
2023-01-26 00:07:49 -08:00
- Markdown to HTML converting (use `html_body` , not `body` )
2021-07-13 18:23:48 +02:00
- file attachments (supports globbing)
2021-04-25 16:45:57 +02:00
2019-11-18 13:23:22 +01:00
## Usage
```yaml
- name: Send mail
2025-12-25 11:16:10 +01:00
uses: dawidd6/action-send-mail@<REF>
2025-06-14 23:10:25 +02:00
env:
# Optional http proxy:
HTTP_PROXY: http://proxy.example.test:3128
2019-11-18 13:23:22 +01:00
with:
2022-09-09 19:53:48 +03:00
# Specify connection via URL (replaces server_address, server_port, secure,
# username and password)
#
# Format:
#
# * smtp://user:password@server:port
# * smtp+starttls://user:password@server:port
connection_url: ${{secrets.MAIL_CONNECTION}}
2026-03-13 10:51:21 +01:00
2022-09-09 19:53:48 +03:00
# Required mail server address if not connection_url:
2019-11-18 13:23:22 +01:00
server_address: smtp.gmail.com
2026-03-13 10:51:21 +01:00
2022-09-09 19:53:48 +03:00
# Server port, default 25:
2019-11-18 13:23:22 +01:00
server_port: 465
2026-03-13 10:51:21 +01:00
2022-09-09 19:53:48 +03:00
# Optional whether this connection use TLS (default is true if server_port is 465)
secure: true
2026-03-13 10:51:21 +01:00
2023-01-05 10:39:58 +00:00
# Optional (recommended) mail server username:
2019-11-18 13:23:22 +01:00
username: ${{secrets.MAIL_USERNAME}}
2026-03-13 10:51:21 +01:00
2021-06-14 20:04:27 +02:00
# Optional (recommended) mail server password:
2019-11-18 13:23:22 +01:00
password: ${{secrets.MAIL_PASSWORD}}
2026-03-13 10:51:21 +01:00
2021-04-25 22:11:54 +08:00
# Required mail subject:
2019-11-18 13:23:22 +01:00
subject: Github Actions job result
2026-03-13 10:51:21 +01:00
# Optional recipients. Separate multiple addresses by a comma (possibly surrounded by whitespace):
to: obiwan@example .com, yoda@example .com
# Required sender (supported formats: see "Supported address formats" below)
2026-03-10 10:08:10 +01:00
from: 'Luke Skywalker <user@example .com>'
2026-03-13 10:51:21 +01:00
2021-04-25 22:11:54 +08:00
# Optional plain body:
body: Build job of ${{github.repository}} completed successfully!
2026-03-13 10:51:21 +01:00
2021-04-25 22:11:54 +08:00
# Optional HTML body read from file:
html_body: file://README.html
2026-03-13 10:51:21 +01:00
# Optional carbon copy recipients. Separate multiple addresses by a comma (possibly surrounded by whitespace):
cc: 'kyloren@example .com, "Her Majesty, Princess Leia" <leia@example .com>'
# Optional blind carbon copy recipients. Separate multiple addresses by a comma (possibly surrounded by whitespace):
bcc: r2d2@example .com, hansolo@example .com
2021-04-25 22:11:54 +08:00
# Optional recipient of the email response:
2021-04-07 18:34:58 +01:00
reply_to: luke@example .com
2026-03-13 10:51:21 +01:00
2021-10-17 09:45:58 +02:00
# Optional Message ID this message is replying to:
2026-03-13 10:51:21 +01:00
in_reply_to: '<3cc627c8-6181-453b-d90b-04aae9e23b21@github .com>'
2021-04-02 00:02:58 +02:00
# Optional unsigned/invalid certificates allowance:
ignore_cert: true
2026-03-13 10:51:21 +01:00
2020-11-30 12:51:34 -05:00
# Optional converting Markdown to HTML (set content_type to text/html too):
convert_markdown: true
2026-03-13 10:51:21 +01:00
2020-04-07 10:36:16 +02:00
# Optional attachments:
2021-07-13 18:23:48 +02:00
attachments: attachments.zip,git.diff,./dist/static/*.js
2026-03-13 10:51:21 +01:00
2021-07-02 12:33:56 -04:00
# Optional priority: 'high', 'normal' (default) or 'low'
priority: low
2026-03-13 10:51:21 +01:00
2026-02-27 12:38:27 +00:00
# Optional custom headers:
headers: '{"X-Priority": "3 (Normal)", "X-My-Header": "MyValue"}'
2026-03-13 10:51:21 +01:00
2024-01-05 18:40:18 +01:00
# Optional nodemailerlog: true/false
nodemailerlog: false
2026-03-13 10:51:21 +01:00
# Optional nodemailerdebug: true/false if true nodemailerlog will also be set true
2024-01-05 18:40:18 +01:00
nodemailerdebug: false
2026-03-13 10:51:21 +01:00
2025-04-08 14:36:45 -04:00
# Optional custom SMTP MAIL FROM address (overrides username):
envelope_from: mailer@example .com
2026-03-13 10:51:21 +01:00
# Optional custom SMTP RCPT TO addresses (overrides to, cc, bcc). Separate multiple addresses by a comma (possibly surrounded by whitespace):
envelope_to: mailer@example .com, admin@example .com
2019-11-18 13:23:22 +01:00
```
2026-03-13 10:51:21 +01:00
### Remark for `envelope_from` and `envelope_to`
[nodemailer ](https://nodemailer.com/ ) (the node module that does the actual sending) requires that if the optional custom envelope is used, **both ** its attributes `from` and `to` must be set. To facilitate setting only one of `envelope_from` or `envelope_to` , this action sets the other one from the regular message fields in the following way:
* If only `envelope_from` is set, `envelope_to` will be set to the concatenation of `to` , `cc` and `bcc` (with duplicates removed).
* If only `envelope_to` is set, `envelope_from` will be set to the address specified in `from` .
### Supported address formats
This action now uses nodemailer's addressparser. The supported address formats are described [here ](https://nodemailer.com/message/addresses ).
Mail addresses can contain YAML special characters like '<' and '>'. To avoid YAML parsing issues, addresses that contain such characters should be enclosed in single quotes.
2021-04-13 13:24:22 -05:00
## Troubleshooting
### Gmail
2022-03-18 14:58:04 -07:00
Instead of using your normal Google password, use an App password.
2021-04-13 13:24:22 -05:00
2025-06-14 23:10:25 +02:00
1. [Enable 2-Step Verification ](https://support.google.com/accounts/answer/185839?hl=en&co=GENIE.Platform%3DAndroid ). This is needed to create an App password.
2022-03-18 14:58:04 -07:00
2. [Create an App password ](https://support.google.com/accounts/answer/185833?hl=en ) for `Mail` .
2021-06-14 20:04:27 +02:00
### 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.