# Sending E-mails

#### Environment Variables

**MAIL\_URL:** The server reads from the *MAIL\_URL* environment variable to determine how to send mail. The *MAIL\_URL* should reference an [SMTP](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol) server and use the form:

```
smtp://USERNAME:PASSWORD@HOST:PORT
```

**or**

```
smtps://USERNAME:PASSWORD@HOST:PORT
```

The smtp**s**:// form (the **s** is for “**secure**”) should be used if the **mail server requires TLS/SSL** (and does not use STARTTLS) and is most common on port 465. Connections which start unencrypted prior to being upgraded to TLS/SSL (using STARTTLS) typically use port 587 (and sometimes 25) and should use **smtp://**. For more information see the [Nodemailer](https://nodemailer.com/smtp/) docs

#### Docker Setup

The MAIL\_URL can be passed to Docker with the -e parameter:

```
docker run --name titra -p 3000:3000 --link mongodb -e MONGO_URL=mongodb://mongodb/titra -e ROOT_URL=http://localhost:3000 -e MAIL_URL=smtp://USERNAME:PASSWORD@HOST:PORT kromit/titra
```

It can also be added in a similar way with docker-compose:

```
version: '3'
services:
  titra:
    image: kromit/titra
    container_name: titra_app
    depends_on:
      - mongodb
    environment:
      - ROOT_URL=${ROOT_URL}
      - MONGO_URL=mongodb://mongodb/titra?directConnection=true
      - PORT=3000
      - MAIL_URL=smtp://USERNAME:PASSWORD@HOST:PORT
    ports:
      - "3000:3000"
    restart: always
  mongodb:
    image: mongo:5.0
    container_name: titra_db
    restart: always
    environment:
      - MONGO_DB:titra
    volumes:
      - titra_db_volume:/data/db
volumes:
  titra_db_volume:
```