pivotal-cf/email-resource

Name: email-resource

Owner: Pivotal Cloud Foundry

Description: A Concourse resource that sends emails

Created: 2015-08-03 21:40:02.0

Updated: 2018-03-27 18:20:09.0

Pushed: 2018-05-13 17:05:45.0

Homepage:

Size: 408

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Email Resource

A Concourse resource that sends emails.

Getting started

Add the following Resource Type to your Concourse pipeline

urce_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
source:
Parameters

Within smtp:

Within source:

An example source configuration is below.

urces:
me: send-an-email
pe: email
urce:
smtp:
  host: smtp.example.com
  port: "587" # this must be a string
  username: a-user
  password: my-password
from: build-system@example.com
to: [ "dev-team@example.com", "product@example.net" ] #optional if `params.additional_recipient` is specified

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

urces:
me: send-an-email
pe: email
urce:
smtp:
  host: smtp.example.com
  port: "587" # this must be a string
  anonymous: true
from: build-system@example.com
to: [ "dev-team@example.com", "product@example.net" ]

An exmaple using custom certificates:

urces:
me: send-an-email
pe: email
urce:
smtp:
  host: smtp.example.com
  port: "587" # this must be a string
  anonymous: true
  ca_cert: |
    -----BEGIN CERTIFICATE-----
    ...
    -----END CERTIFICATE-----
from: build-system@example.com
to: [ "dev-team@example.com", "product@example.net" ] 

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

For example, a build plan might contain this:

put: send-an-email
params:
  subject: generated-subject-file
  body: generated-body-file

For example, a build plan might contain this if using generated list of recipient(s):

put: send-an-email
params:
  subject: generated-subject-file
  body: generated-body-file
  to: generated-to-file

You can use the values below in any of the source files or text properties to access the corresponding metadata made available by concourse, as documented here

For example:

put: send-an-email
params:
  subject_text: "Build finished: ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME}"
  body_text: "Build finished: ${ATC_EXTERNAL_URL}/teams/main/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}"
HTML Email

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

-version: 1.0
ent-Type: text/html; charset="UTF-8"
Build from the source

email-resource is written in Go. To build the binary yourself, follow these steps:

To cross compile, set the $GOOS and $GOARCH environment variables. For example: GOOS=linux GOARCH=amd64 go build.

Testing

To run the unit tests, use go test $(glide nv).


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.