GithubHelp home page GithubHelp logo

anwarchk / email-resource Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pivotal-cf/email-resource

0.0 1.0 0.0 2.81 MB

A Concourse resource that sends emails. This version of the email-resource allows template based subject and body files

License: MIT License

Go 96.54% Shell 3.46%

email-resource's Introduction

Email Resource

A Concourse resource that sends emails.

Getting started

Add the following Resource Type to your Concourse pipeline

resource_types:
  - name: email
    type: docker-image
    source:
      repository: pcfseceng/email-resource

Look at the demo pipeline for a complete example.

This resource acts as an SMTP client, using PLAIN auth over TLS. So you need an SMTP server that supports all that.

For development, we've been using Amazon SES with its SMTP support

Source Configuration

An example source configuration is below. None of the parameters are optional.

resources:
- name: send-an-email
  type: email
  source:
    smtp:
      host: smtp.example.com
      port: "587" # this must be a string
      username: a-user
      password: my-password
    from: [email protected]
    to: [ "[email protected]", "[email protected]" ]

An example source configuration is below supporting sending email when anonymous is permitted.

resources:
- name: send-an-email
  type: email
  source:
    smtp:
      host: smtp.example.com
      port: "587" # this must be a string
      anonymous: true
    from: [email protected]
    to: [ "[email protected]", "[email protected]" ]

Note that to is an array, and that port is a string. If you're using fly configure with the --load-vars-from (-l) substitutions, every {{ variable }} automatically gets converted to a string. But for literals you need to surround it with quotes.

Behavior

This is an output-only resource, so check and in actions are no-ops.

out: Send an email

Parameters

  • headers: Optional. Path to plain text file containing additional mail headers
  • subject: Required. Path to plain text file containing the subject
  • body: Required. Path to file containing the email body.
  • send_empty_body: Optional. If true, send the email even if the body is empty (defaults to false).
  • istemplatesubject Optional. If true, subject file is assumed to contain concourse env variables to be replaced (defaults to false).
  • istemplatebody Optional. If true, body file assumed to contain concourse en variables to be replaced (defaults to false).

A build plan might contain this:

  - put: send-an-email
    params:
      subject: demo-prep-sha-email/generated-subject
      body: demo-prep-sha-email/generated-body

If using template files, the generated subject and body files should contain place holders to be replaced with Concourse build metadata. For eg, a generated template file with Concourse metadata place holders would look something like this :

echo "Build {{.BuildJobName }} of {{.BuildPipelineName}} pipeline failed" >> ./emailout/email-subject-failure.txt

echo "Build {{.BuildName }} of job {{.BuildJobName }} for pipeline {{.BuildPipelineName}} failed." >> ./emailout/email-body-failure.txt

echo "Please see the build details here : {{.ExternalURL }}/teams/{{.BuildTeamName}}/pipelines/{{.BuildPipelineName}}/jobs/{{.BuildJobName}}/builds/{{.BuildName}}" >> ./emailout/email-body-failure.txt

HTML Email

To send HTML email set the headers parameter to a file containing the following:

MIME-version: 1.0
Content-Type: text/html; charset="UTF-8"

Build from the source

Get yourself familiarized with Godep [https://github.com/tools/godep]. Download it and then add it your path. Then run

godep go build -o bin/check ./actions/check

godep go build -o bin/in ./actions/in

godep go build -o bin/out ./actions/out

To run the tests

cd tests

godep go test

email-resource's People

Contributors

rosenhouse avatar mmb avatar dsabeti avatar aramprice avatar calebwashburn avatar goutamtadi1 avatar jdeppe-pivotal avatar

Watchers

 avatar

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.