Git Product home page Git Product logo

action-send-mail's Introduction

Send mail GitHub Action

An action that simply sends a mail to multiple recipients.

Some features:

  • plain text body
  • HTML body
  • multipart body (plain text + HTML)
  • Markdown to HTML converting (use html_body, not body)
  • file attachments (supports globbing)

Usage

- name: Send mail
  uses: dawidd6/action-send-mail@v3
  with:
    # 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}}
    # Required mail server address if not connection_url:
    server_address: smtp.gmail.com
    # Server port, default 25:
    server_port: 465
    # Optional whether this connection use TLS (default is true if server_port is 465)
    secure: true
    # Optional (recommended) mail server username:
    username: ${{secrets.MAIL_USERNAME}}
    # Optional (recommended) mail server password:
    password: ${{secrets.MAIL_PASSWORD}}
    # Required mail subject:
    subject: Github Actions job result
    # Required recipients' addresses:
    to: [email protected],[email protected]
    # Required sender full name (address can be skipped):
    from: Luke Skywalker # <[email protected]>
    # 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:
    cc: [email protected],[email protected]
    # Optional blind carbon copy recipients:
    bcc: [email protected],[email protected]
    # Optional recipient of the email response:
    reply_to: [email protected]
    # Optional Message ID this message is replying to:
    in_reply_to: <[email protected]>
    # Optional unsigned/invalid certificates allowance:
    ignore_cert: true
    # Optional converting Markdown to HTML (set content_type to text/html too):
    convert_markdown: true
    # Optional attachments:
    attachments: attachments.zip,git.diff,./dist/static/*.js
    # Optional priority: 'high', 'normal' (default) or 'low'
    priority: low
    # Optional nodemailerlog: true/false
    nodemailerlog: false
    # Optional nodemailerdebug: true/false if true lognodem will also be set true
    nodemailerdebug: false

Troubleshooting

Gmail

Instead of using your normal Google password, use an App password.

  1. Enable 2-Step Verification.. This is needed to create an App password.
  2. Create an App password for Mail.

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 to make the email delivery secure.

action-send-mail's People

Contributors

a08381 avatar alonbl avatar benjyw avatar cbbm142 avatar charlie-cadmv avatar danielhomola avatar dawidd6 avatar dependabot-preview[bot] avatar dependabot[bot] avatar dougpagani avatar droidpl avatar furtber avatar heinrichreimer avatar jiacai2050 avatar jimfilippou avatar jj-connect avatar justingosses avatar kroese avatar krzywiecki avatar legedith avatar matttbe avatar melissachang avatar phoeniixhawk avatar simonwep avatar sturman avatar tremblaysimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

action-send-mail's Issues

Make username and password optional for Self-Hosted runner use cases

Context

Related issue: #10

@dawidd6 Thanks for providing this really handy action.

Problem

I am relating the issue #10 where this was addressed, and I can see a use case where having username/password optional can be really handy. This is for self-hosted runners, where they have access to internal infrastructure and smtp services. In those cases, the smtp server can work without authentication and it's secure from the access through the internet. If this is or it's not a questionable practice within the enterprise environment is something that can be discussed, but certainly there is audience where this may be interesting.

Solution

I would suggest, and if you agree I am happy to create a PR, that we make username/password optional and put a warning message in the case people do it to make sure they are aware of the risk.

Optionally we can set a boolean parameter to ack that they are doing something that may potentially be insecure if you want to make this more explicit.

Proposed changes

The changes required would be:

  • Remove the required restriction for username/password
  • Add a warning message printed on the log
  • (Optional) add an ack parameter to explicitly say you want to be using a non authenticated smtp request
  • Add documentation to the readme

What are your thoughts? 😸

How to use SES to send emails for job failure

I am using the below code snippet for sending emails for action status using AWS SES. But i am keep facing issue fro from address

if: always()
     uses: dawidd6/action-send-mail@v3
     with:
       # mail server settings
       server_address: ${{secrets.SMTP_HOST}}
       server_port: 465
       # Optional (recommended): mail server username:
       username: ${{secrets.SMTP_USERNAME}}
       # Optional (recommended) mail server password:
       password: ${{secrets.SMTP_PASSWORD}}
       # email subject
       subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
       # email body as text
       body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
       # comma-separated string, send email to
       to: [email protected]
       # from email name
       from: [email protected]

support multiple part email

Email contains both text and html is common, but this action can only send one of them inside an email.
BTW, Nodemailer support multiple-part email, I would like to contribute a PR if this feature make sense to you.

gmail

Is it possible to use this action with gmail? It seems to get blocked.

Thanks :)!

html_body is invalid

Got this error from git action.

Warning: Unexpected input(s) 'html_body', valid inputs are ['server_address', 'server_port', 'username', 'password', 'subject', 'body', 'to', 'from', 'cc', 'bcc', 'reply_to', 'ignore_cert', 'content_type', 'convert_markdown', 'attachments']

How could I set multi-line content in the body part?

hello, I want to send an email with long content, I put the content after body, but it reported error if I split the content into multi-line.

body: Email content:


Please find the error notification below
incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line

Given gmail is listed in template, provide additional gmail specific instructions for common pain points

I ran into similar problems that I've seen several people have in other issues/questions. Given gmail is used in template, might be worth noting in README that gmail server access will be blocked as "security issue" unless:

    • "Less Secure" Apps need to be enabled in google profile. Can't find a static link for this, but if you go to google profile settings and put "less secure apps" in the search bar instructions will come up.
    • If you the gmail account in question as 2FA enabled, the 2FA password will need to be provided as well, which isn't included in the default template.

After I did the first two steps and switched to an account without 2FA, the GitHubAction worked and I didn't get security messages from google.

How can I retrieve attachment from IMAP Mail Server

How can I retrieve attachments from IMAP Mail Server?

${{on.email.outputs.attachments}} returns empty value. But the fact is I've sent an attachment to the concerned email server from where I'm retrieving data.

on:
  email:
    imap:
      host: imap.example.com
      user: ${{secrets.EMAIL_USER}}
      password: ${{secrets.EMAIL_PASSWORD}}

     - name: Send mail via zohomail
        uses: dawidd6/action-send-mail@v3
        with:
          # Required mail server address:
          server_address: smtp.zoho.in
          # Required mail server port:
          server_port: 465
          # Optional (recommended): mail server username:
          username:  ${{secrets.EMAIL_USER}}
          # Optional (recommended) mail server password:
          password: ${{secrets.EMAIL_PASSWORD}}
          # Required mail subject:
          subject: Re ${{(on.email.outputs.subject)}}
          # Required recipients' addresses:
          to:  ${{(on.email.outputs.from.value[0].address)}}
          # Required sender full name (address can be skipped):
          from: ${{ secrets.FROM_EMAIL_ID }}
          # Optional whether this connection use TLS (default is true if server_port is 465)
          secure: true
          # Optional plain body:
          body: |
                ${{(on.email.outputs.text)}}
          # Optional recipient of the email response:
          reply_to: ${{ secrets.FROM_EMAIL_ID }}
          # Optional unsigned/invalid certificates allowance:
          ignore_cert: true
          # Optional converting Markdown to HTML (set content_type to text/html too):
          convert_markdown: true
          # Optional attachments:
          attachments: ${{(on.email.outputs.attachments)}}

Send mail Github Action || Zipped Files are not sent as part of the attachments

Sending attachments as a .zip file which is generated using github actions --> papeloto/action-zip@v1

Able to send the single HTML file in email but zipped package is not getting sent. Workflow is running without error but the attachment is missing in the email.

  • name: Zip Package
    uses: papeloto/action-zip@v1
    with:
    files: cypress/reports/
    dest: result.zip
    - name : Upload Artifact
    uses: actions/upload-artifact@v1
    with:
    name: Test_Cypress_Report
    path: ${{ github.workspace }}/result.zip
    - name: Send mail
    uses: dawidd6/action-send-mail@v3
    with:
    server_address: smtp.gmail.com
    server_port: 465
    username: ${{secrets.MAIL_USERNAME}}
    password: ${{secrets.MAIL_PASSWORD}}
    subject: Github Actions job result
    to: [email protected]
    html_body: cypress/reports/Result/index.html
    from: QA
    body: 'Build job of ${{github.repository}} - Testing Report completed successfully!'
    content_type: application/zip
    attachments: '[{"path":${{ github.workspace }}//result.zip}]'

Templating?

Hi,

Is it possible to set the body value to a file and have values interpolated within it?

i.e.

# workflow.yml
    - name: Notify Email
      uses: dawidd6/action-send-mail@v2
      with:
        server_address: smtp.gmail.com
        server_port: 465
        username: ${{ secrets.MAIL_USERNAME }}
        password: ${{ secrets.MAIL_PASSWORD }}
        subject: Test
        body: file://templates/test.html
        to: ${{ env.email_address }}
        from: Test
        content_type: text/html
# templates/test.html
<p>Hello ${{ env.name }} !</p>

I've tried this directly but it doesn't interpolate the values.

[feature] send mail without autorization using my own server

I want to be able to send e-mails to my domain using my server without authentication. Please add this feature.

Currently I got error
##[error]Input required and not supplied: username
My config is

- name: Send mail
        uses: dawidd6/action-send-mail@v2
        with:
          server_address: my.mx.server.com
          server_port: 25
          username: null
          password: null
          subject: Github Actions job result
          # Literal body:
          body: Build job of ${{github.repository}} completed successfully!
          # Read file contents as body:
          to: [email protected]
          from: <>
          # Optional content type (defaults to text/plain):
          content_type: text/plain

Option to add attachments

It would be nice to have an option to add attachments to email message, e.g.

- name: Send mail
  uses: dawidd6/action-send-mail@v2
  with:
    server_address: smtp.gmail.com
    server_port: 465
    username: ${{secrets.MAIL_USERNAME}}
    password: ${{secrets.MAIL_PASSWORD}}
    subject: Github Actions job result
    # Literal body:
    body: Build job of ${{github.repository}} completed successfully!
    # Read file contents as body:
    body: file://README.md
    to: [email protected],[email protected]
    from: Luke Skywalker # <[email protected]>
    # Optional content type (defaults to text/plain):
    content_type: text/html
    attachments:
      - filename: 'text1.txt'
        content: 'aGVsbG8gd29ybGQh'
        encoding: 'base64'
      - filename: git.diff
      - filename: 'license.txt',
        path: 'https://raw.github.com/nodemailer/nodemailer/master/LICENSE'

Note: nodemailer doc about attachments https://nodemailer.com/message/attachments/

[Issue] Supporting Encryption type: SSL, TLS and STARTTLS

I tried to use Outlook mail to send the emails, however, it always fails. I noticed the encryption type of Outlook and Gmail, which your give in your example, is different. Then I changed the to a Gmail account, it works well.

Outlook:
image
Gmail:
image

[Support] I am wondering if it's possible to support different encryption types in the options? like:
encryption: STARTTLS

Thanks

Allow globs for attachments

Hey! First of all thanks for this really nice action!

It'd be cool to be able to use globs for attachments:

- name: Send mail
  uses: dawidd6/action-send-mail@v3
  with:
    attachments: docs/*.pdf # Glob path!

This would attach all .pdf files in the ./docs folder as single files.

I see that you're using JavaScript so glob might be something to use here?

more files need be sent - solved

when I build fail in github actions, cmake create two log files. I wrote this:

    - name: Send mail
      uses: dawidd6/action-send-mail@master
      with:
        serveraddress: smtp.163.com
        serverport: 465
        username: ${{ secrets.MAILUSERNAME_LOG }}
        password: ${{ secrets.MAILPASSWORD_LOG }}
        subject: Error log for cmake
        body: 
          - file://cpp/trunk/fips-build/code/windows/CMakeFiles/CMakeOutput.log
          - file://cpp/trunk/fips-build/code/windows/CMakeFiles/CMakeError.log
        to: [email protected]
        from: GitHub Actions
        content_type: text/html

and recieve error:

### ERRORED 07:18:29Z

- Your workflow file was invalid: The pipeline is not valid. .github/workflows/windows.yml (Line: 28, Col: 11): A sequence was not expected

So, how to write when I need TWO or MORE FILES to be sent???

Sending emails with iCloud

Hi

I tried to send an email via iCloud:

jobs:
  notification:
    runs-on: ubuntu-latest
    steps:
      - name: Send notification to editors
        uses: dawidd6/action-send-mail@v3
        with:
          server_address: smtp.mail.me.com
          server_port: 587
          username: ${{secrets.MAIL_USERNAME}}
          password: ${{secrets.MAIL_PASSWORD}}
          subject: Subject
          to: ${{secrets.MAIL_TO}}
          from: ${{secrets.MAIL_FROM}}
          secure: true
          body: |
            Multi line
            text
          ignore_cert: true

I've created an app-specific password (as mentioned here: https://support.apple.com/en-us/HT202304) but I always get the error

139634851661696:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

CSS in HTML body not working

When I add a simple HTML file with some CSS in the head it's not rendering CSS.

Expected: CSS to be rendered
Got: 0 read CSS

Could not find file 'showndown'

Hi, I got an error when action built up :

Error:
Could not find file '/home/runner/work/_actions/_temp_ab0eda08-6b5b-44d1-9038-11fc4752310d/_staging/dawidd6-action-send-mail-a1ab281/node_modules/.bin/showdown'.

I used the version 3.

Add option to disable TLS

While trying to use your action I got this error:
Error: SSL_connect returned=1 errno=0 state=error: wrong version number
I've tried adding an option to disable_tls, but then I'm getting this error:
Error: 504 5.7.4 Unrecognized authentication type

Sadly I'm not a Ruby programmer, so I can't help with this.

In one of the apps I use (Redmine - it is in Ruby) I have this config:

 email_delivery:
    delivery_method: :smtp
    smtp_settings:
      tls: false
      address: mail.example.com
      port: 25

ref: (https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration)

html_body does not work

Hi,

When add the single page report as an html body to outlook email by using a github action, It is seen css codes before the report itself.
My question is why css codes are seen in the report? How can I remove?

image

Single Page Report.zip

I am trying to show such daily report in the email.

This is the code part in .yml file ho I use
image

Problems with sendgrid

Hi, I was wondering if this was tested with Send Grid, I get an error claiming the from address is not from a valid Sender (you have to validate an email with them for this), and I think it's because the field is being sent between <>

Anyone else with this problem? Anyone know a workaround?

Hide multiple email addresses from log output

If you put more than one email address in to, cc or bcc, the action-send-mail log shows the full email addresses even if it is passed in from a secret (because in the secret, it is comma separated so GitHub Actions doesn't know how to hide the split individual email addresses in the log output).

I think that action-send-mail email addresses should be hidden in the log or there should be an option not to output the log at all.

Gmail sign in without "Less secure apps"

It looks like Google is phasing out "Less secure apps" functionality... is there a way to integrate with Gmail using OAuth instead? I tried looking around for a github action that does this and couldn't find any.

html_body not working

hello,
i'm about to send an email using github actions , the probleme i want to send a html body in this email ''ENOENT: no such file or directory'' , however the path that i past it is true , i'm also trying with readme.md but i found the same result
image

image

Err: Greeting Never Received

Getting an error here,

Error: Greeting never received

Looked through the action code, don't see any reference to "Greeting"

Please advise

markdown format support

Hi there,

Thanks for providing this email sending action. I am using this in my project now. I wrote my readme in markdown format, so I wonder if this could support the markdown format in the content.

SSL Error

Trying to configure this action with GSuite Gmail and getting the following error message even though I've configured it to not enforce SSL and ignore invalid certs:

Error: 140308877371264:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

Anybody else having the same issue?
Screen Shot 2021-06-01 at 12 59 40 PM
Screen Shot 2021-06-01 at 1 00 06 PM

Body can't find file

Action fails, cant find body file. readme.md file is in the root of the repo.


name: Email
on:
  push:
    branches: [ "main" ]
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Send mail
        uses: dawidd6/action-send-mail@v3
        with:
          server_address: smtp.gmail.com
          server_port: 465
          username: ${{secrets.MAIL_USERNAME}}
          password: ${{secrets.MAIL_PASSWORD}}
          subject: 42069
          to: [email protected]
          from: mmmmm
          secure: true
          body: file://readme.md
          ignore_cert: true
          convert_markdown: true
          attachments: ./*.pdf
          priority: normal

Use URL as single input parameter for credentials

Hi,

Thank you for the action.

In order to reduce the number of secrets/environment/configuration it would be great if you support receiving a single URL for identity, something like:

source_url: smtp://{username}:{password}@{server_address}:{server_port}/
source_url: smtp+starttls://{username}:{password}@{server_address}:{server_port}/

This will allow a single secret called MAIL_SOURCE_URL (or anything similar) to be used as atomic identity with complete information.

The rational is that the user/password are tied to the server and server is tied to the port and protocol... so in order to keep a generic workflow we need at least these as configuration, URL notation supports this rational.

Thanks,

Attachment name should only be the filename instead of the complete path

I was successful in adding attachments to the email but the attachments name contains the complete file path which looks odd. None of the email apps or any app uploading an attachment uses the complete file path when sending attachments. All of them just use the filename.
Perhaps this awesome github action should do the same.

you can see the below image where the compelte file path is mentioned instead of just hello.c
image

Error: unable to verify the first certificate

Issue: Trying to hit the mail server which is already running on an un-secured port 25. Some reason when running on self-hosted runner and job on a docker container, it is giving the following error:

Run dawidd6/[email protected]
  with:
    server_address: example.example.com
    server_port: 25
    username: username <keeping this blank as unsecured>
    password: password <keeping this blank as unsecured>
    subject: Github Actions job result
    body: Build job of <orgname>/<reponame>! your job is failed and needs to verify
    to: [email protected]
    from: [email protected]
    content_type: text/html
/usr/bin/docker exec  <*********> sh -c "cat /etc/*release | grep ^ID"
Error: unable to verify the first certificate

Composing hyperlink in email body using Markdown

Hey,

I tried to compose a hyperlink in the email body but didn't work.

I tried this:

...
body: [google](https://google.com)
convert_markdown: true

My expectation is to see something like this: google

Any idea how to do that?

How can I mark email as read?

How can I mark the email read or delete it from the IMAP Mail server after it's been processed?

I have a use case where I don't want to retrieve the unread emails.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.