Skip to content

A microservice to send emails from Trellis using sendgrid.

License

Notifications You must be signed in to change notification settings

trellisfw/abalonemail

Repository files navigation

abalonemail

A microservice to send emails in response to job queue items using sendgrid. Example job queue item:

{
  "service": "abalonemail",
  "type": "email",
  "config": {
    "multiple": false,
    "from": "[email protected]",
    "to": {
      "name": "Billy bob",
      "email": "[email protected]"
    },
    "subject": "Test mail",
    "templateData": {
      "foo": "bar"
    },
    "text": "Test!",
    "html": "<h1>Test: {{ foo }}</h1>",
    "attachments": [
      {
        "content": "RXhhbXBsZSBkYXRh",
        "filename": "test.dat",
        "type": "plain/text"
      }
    ]
  }
}

Checkout @oada/formats for a more detailed description of the format.

The from address and the sendgrid API key are set with .env. For example:

domain=oada.example.org
token=ajxhcjkal7y83hdsjkhc8l2
apiKey=aksdjca83d.asdfkxjjc93cSDFUsDaAfaj23FEVhSDvksljsadv0CdADs3V0g84rjksdf

Installation

cd /path/to/your/oada-srvc-docker
cd services-available
git clone [email protected]:trellisfw/abalonemail.git
cd ../services-enabled
ln -s ../services-available/abalonemail .

Overriding defaults for production

Using z_tokens method from oada-srvc-docker, the following docker-compose entry overrides configs for production:

  abalonemail:
    environment:
      - TOKEN=aproductiontokentouse
      - DOMAIN=your.trellis.domain
      - API_KEY=thekeyforsendgridsapi