GitHub Action to send email via SMTP — plain text, HTML, or with attachments.
- name: Failure notification
if: failure()
uses: simonsfoundation/action-send-mail@v1
with:
server_address: ${{ secrets.SMTP_SERVER }}
server_port: 587
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
subject: "[GitHubAction] Failed ${{ github.workflow }} #${{ github.run_number }}"
to: ${{ vars.EMAIL_RECIPIENT }}
from: Github Actions <gh-action@simonsfoundation.org>
body: |
Hello!
Workflow "${{ github.workflow }}" has encountered a failure in the GitHub Action.
Please review the log at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
Contact developer if you need assistance.
| Input | Required | Default | Description |
|---|---|---|---|
server_address |
yes | — | SMTP server hostname |
server_port |
no | 587 |
SMTP server port |
secure |
no | false |
true = direct TLS (port 465); false = STARTTLS |
username |
no | — | SMTP auth username |
password |
no | — | SMTP auth password |
subject |
yes | — | Email subject |
to |
yes | — | Recipient(s), comma-separated |
from |
yes | — | FROM address, e.g. Display Name <user@example.com> |
envelope_from |
no | — | Envelope FROM for bounces/SPF. Defaults to from. |
reply_to |
no | — | Reply-To address |
cc |
no | — | CC recipients, comma-separated |
bcc |
no | — | BCC recipients, comma-separated |
body |
no | — | Plain text body |
html_body |
no | — | HTML body. If both set, sends multipart message. |
attachments |
no | — | File paths to attach, comma-separated. Supports globs. |
ignore_cert |
no | false |
Ignore TLS certificate errors (not recommended) |
priority |
no | normal |
Email priority: high, normal, or low |
At least one of body or html_body must be provided.
| Output | Description |
|---|---|
result |
Response message from the SMTP server |
- uses: simonsfoundation/action-send-mail@v1
with:
server_address: smtp.gmail.com
server_port: 587
username: ${{ secrets.GMAIL_USER }}
password: ${{ secrets.GMAIL_APP_PASSWORD }}
subject: Deployment complete
to: alice@example.com, bob@example.com
from: ${{ secrets.GMAIL_USER }}
body: |
Deployment of ${{ github.repository }} finished.
Commit: ${{ github.sha }}- uses: simonsfoundation/action-send-mail@v1
with:
server_address: smtp.example.com
server_port: 465
secure: true
username: ${{ secrets.SMTP_USER }}
password: ${{ secrets.SMTP_PASS }}
subject: Report ready
to: reports@example.com
from: noreply@example.com
html_body: |
<h1>Report</h1>
<p>Run <strong>#${{ github.run_number }}</strong> completed.</p>- name: Build report
run: make report.pdf
- uses: simonsfoundation/action-send-mail@v1
with:
server_address: smtp.example.com
server_port: 587
username: ${{ secrets.SMTP_USER }}
password: ${{ secrets.SMTP_PASS }}
subject: Weekly report
to: manager@example.com
from: ci@example.com
body: See attached report.
attachments: report.pdf- uses: simonsfoundation/action-send-mail@v1
with:
server_address: smtp.example.com
server_port: 587
username: ${{ secrets.SMTP_USER }}
password: ${{ secrets.SMTP_PASS }}
subject: Notification
to: user@example.com
from: Notifications <notifications@example.com>
envelope_from: bounces@example.com
body: This is a notification.npm install
npm run build # produces dist/index.jsCommit dist/ — GitHub Actions runs the bundled file directly.
MIT — Simons Foundation