This is a simple GitHub Action for sending emails via these services:
It uses the Python stdlib exclusively, there are no other dependencies - send_email.py is the script.
Required environment variables:
POSTMARK_API_TOKENorRESEND_API_KEY- Depending on the provider you're usingEMAIL_FROM- Email "From" addressEMAIL_TO- Email "To" address
Values used in the workflow:
provider- Eitherpostmarkorresendsubject- The email subjectbody_textand/orbody_html- The email body (at least one required)
Add a step to your Actions code like this:
- uses: case/actions-email@v1
env:
POSTMARK_API_TOKEN: ${{ secrets.POSTMARK_API_TOKEN }} # If using Postmark
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }} # If using Resend
EMAIL_FROM: ${{ secrets.EMAIL_FROM }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
with:
provider: resend # Or "postmark"
subject: "Build completed"
body_html: "<h1>Success!</h1>"To test this locally, make sure you have the RESEND_API_KEY env var set. Then run:
$ python3 send_email.py --test --from "[email protected]" --to "[email protected]"