Auth Emails using Sendgrid or Mailgun

Hello @cristi / @dimitrie ~

This is likely a question for @cristi - because it involves the docker-compose.yml config.

Can you add/setup sendgrid or mailgun support to the yml file as you used to be able to define in .env with Speckle 1.0?

OR, better yet, how does one ref a .env file from within the yml file?

Lastly, do you have a template .env file to work with? What is the syntax of this file if many of the params identified there may already be covered in the yml file?

@markcichy
Hi,

If you use the docker-compose yml file, you don’t need an .env file. You can specify the environment variables right in the yml file.

For configuring email, you can add the following env variables directly to your docker-compose yaml file:

EMAIL: "true"
EMAIL_HOST: "<smtp_host>"
EMAIL_PORT: "<smtp_port>"
EMAIL_USERNAME: "<smtp_username>"
EMAIL_PASSWORD: "<smtp_password>"
EMAIL_FROM: "speckle@your-domain.com"

You can get the values smtp_* from your email provider, and the EMAIL_FROM is what source email address to use when sending email on behalf of the speckle server (you must have access to send from that domain in your email provider)

PS: It’s important to include double quotes for "true" and "port". Otherwise the yaml specification will transform them in boolean / integer, but environment variables must be strings.

1 Like

Hi @cristi ~

Receiving this error:

ERROR: In file './docker-compose.yml', service 'EMAIL' must be a mapping not a string.

Lines in docker-compose.yml file are as follows:

EMAIL: "true"
EMAIL_HOST: "smpt.sendgrid.net"
EMAIL_PORT: "587"
EMAIL_USERNAME: "usr**"
EMAIL_PASSWORD: "pwd**"
EMAIL_FROM: "speckle@mobiusnode.io"

Just noticed a spelling error in the domain, regardless, the issue persists…

Hi @markcichy ,

Hmm, EMAIL should be an environment variable, not a service.

The yaml format is very sensitive to indentation. Are you using the correct indentation for those env variables?

If not sure, can u paste the full yaml file? (Replacing just the sensitive values)

They are double spaced like other elements defined within.

version: "3"
services:
  ####
  # Speckle Server dependencies
  #######
  postgres:
    image: "postgres:13.1-alpine"
    restart: always
    environment:
      POSTGRES_DB: speckle
      POSTGRES_USER: **concealed**
      POSTGRES_PASSWORD: **concealed**
    volumes:
      - ./postgres-data:/var/lib/postgresql/data/
    ports:
      - "127.0.0.1:5432:5432"

  redis:
    image: "redis:6.0-alpine"
    restart: always
    volumes:
      - ./redis-data:/data
    ports:
      - "127.0.0.1:6379:6379"

  ####
  # Speckle Server
  #######
  speckle-frontend:
    image: speckle/speckle-frontend:latest
    restart: always
    ports:
      - "0.0.0.0:80:80"

  speckle-server:
    image: speckle/speckle-server:latest
    restart: always
    command: ["bash", "-c", "/wait && node bin/www"]
    environment:
      # TODO: Change this to the URL of the speckle server, as accessed from the network
      CANONICAL_URL: "https://speckletwo.mobiusnode.io"

      SESSION_SECRET: "**concealed**"

      STRATEGY_LOCAL: "true"
      DEBUG: "speckle:*"

      POSTGRES_URL: "postgres"
      POSTGRES_USER: "**concealed**"
      POSTGRES_PASSWORD: "**concealed**"
      POSTGRES_DB: "speckle"

      REDIS_URL: "redis://redis"
      WAIT_HOSTS: postgres:5432, redis:6379

#  EMAIL: "true"
#  EMAIL_HOST: "smtp.sendgrid.net"
#  EMAIL_PORT: "587"
#  EMAIL_USERNAME: "**concealed**"
#  EMAIL_PASSWORD: "**concealed**"
#  EMAIL_FROM: "speckle@mobiusnode.io"

# preview-service:
#     image: speckle/speckle-preview-service:2
#     restart: always
#     mem_limit: "1000m"
#     memswap_limit: "1000m"
#     command: ["bash", "-c", "/wait && node bin/www"]
#     environment:
#       DEBUG: "preview-service:*"
#       PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle"
#       WAIT_HOSTS: postgres:5432

Oh, they must be indented like the other environment variables above (6 spaces, if i’m not mistaken)

2 Likes

That worked! @cristi

3 Likes