Skip to content

Commit

Permalink
Update Docker documentation with correct ports
Browse files Browse the repository at this point in the history
Closes #402.
  • Loading branch information
djfarrelly committed Apr 6, 2022
1 parent bf01db8 commit f4d2f7e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 29 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
## Docker Run

If you want to use MailDev with [Docker](https://www.docker.com/), you can use the
[**soulteary/maildev** image on Docker Hub](https://hub.docker.com/r/soulteary/maildev).
[**maildev/maildev** image on Docker Hub](https://hub.docker.com/r/maildev/maildev).
For a guide for usage with Docker,
[checkout the docs](https://github.com/maildev/maildev/blob/master/docs/docker.md).

$ docker run -p 1080:1080 -p 1025:1025 soulteary/maildev
$ docker run -p 1080:1080 -p 1025:1025 maildev/maildev

## Usage

Expand All @@ -23,22 +23,22 @@ Usage: maildev [options]

| Options | Environment variable | Description |
| -------------------------------- | -------------------------- | ----------------------------------------------------------------------------------------- |
| `-s, --smtp <port>` | `MAILDEV_SMTP_PORT` | SMTP port to catch mail |
| `-s, --smtp <port>` | `MAILDEV_SMTP_PORT` | SMTP port to catch mail |
| `-w, --web <port>` | `MAILDEV_WEB_PORT` | Port to run the Web GUI |
| `--mail-directory <path>` | `MAILDEV_MAIL_DIRECTORY` | Directory for persisting mail |
| `--mail-directory <path>` | `MAILDEV_MAIL_DIRECTORY` | Directory for persisting mail |
| `--https` | `MAILDEV_HTTPS` | Switch from http to https protocol |
| `--https-key <file>` | `MAILDEV_HTTPS_KEY` | The file path to the ssl private key |
| `--https-cert <file>` | `MAILDEV_HTTPS_CERT` | The file path to the ssl cert file |
| `--ip <ip address>` | `MAILDEV_IP` | IP Address to bind SMTP service to |
| `--outgoing-host <host>` | `MAILDEV_OUTGOING_HOST` | SMTP host for outgoing mail |
| `--outgoing-port <port>` | `MAILDEV_OUTGOING_PORT` | SMTP port for outgoing mail |
| `--outgoing-user <user>` | `MAILDEV_OUTGOING_USER` | SMTP user for outgoing mail |
| `--outgoing-pass <password>` | `MAILDEV_OUTGOING_PASS` | SMTP password for outgoing mail |
| `--outgoing-secure` | `MAILDEV_OUTGOING_SECURE` | Use SMTP SSL for outgoing mail |
| `--outgoing-host <host>` | `MAILDEV_OUTGOING_HOST` | SMTP host for outgoing mail |
| `--outgoing-port <port>` | `MAILDEV_OUTGOING_PORT` | SMTP port for outgoing mail |
| `--outgoing-user <user>` | `MAILDEV_OUTGOING_USER` | SMTP user for outgoing mail |
| `--outgoing-pass <password>` | `MAILDEV_OUTGOING_PASS` | SMTP password for outgoing mail |
| `--outgoing-secure` | `MAILDEV_OUTGOING_SECURE` | Use SMTP SSL for outgoing mail |
| `--auto-relay [email]` | `MAILDEV_AUTO_RELAY` | Use auto-relay mode. Optional relay email address |
| `--auto-relay-rules <file>` | `MAILDEV_AUTO_RELAY_RULES` | Filter rules for auto relay mode |
| `--incoming-user <user>` | `MAILDEV_INCOMING_USER` | SMTP user for incoming mail |
| `--incoming-pass <pass>` | `MAILDEV_INCOMING_PASS` | SMTP password for incoming mail |
| `--incoming-user <user>` | `MAILDEV_INCOMING_USER` | SMTP user for incoming mail |
| `--incoming-pass <pass>` | `MAILDEV_INCOMING_PASS` | SMTP password for incoming mail |
| `--web-ip <ip address>` | `MAILDEV_WEB_IP` | IP Address to bind HTTP service to, defaults to --ip |
| `--web-user <user>` | `MAILDEV_WEB_USER` | HTTP user for GUI |
| `--web-pass <password>` | `MAILDEV_WEB_PASS` | HTTP password for GUI |
Expand All @@ -48,7 +48,7 @@ Usage: maildev [options]
| `-o, --open` | | Open the Web GUI after startup |
| `-v, --verbose` | | |
| `--silent` | | |
| `--log-mail-contents` | | Log a JSON representation of each incoming mail |
| `--log-mail-contents` | | Log a JSON representation of each incoming mail |

## API

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3'
services:

maildev:
image: soulteary/maildev
image: maildev/maildev
restart: always
environment:
- TZ=Asia/Shanghai
Expand Down
49 changes: 33 additions & 16 deletions docs/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ Now the MailDev UI will be running at port `1080` on your virtual machine
running at `192.168.99.100`, you can head over to `http://192.168.99.100:1080`
to visit the interface.

## Linking containers

> This is for using [Docker's legacy container links](https://docs.docker.com/network/links/).
Let's say you're using [nodemailer](https://github.com/nodemailer/nodemailer)
in your Node.js app running in another container. Let's link your app's
container with MailDev:

```
$ docker run -p 8080:80 --link maildev yourimage
$ docker run -p 8080:1080 --link maildev yourimage
```

From within your app's container, Docker will expose some helpful environment
Expand All @@ -35,47 +39,53 @@ used to send your emails. Sending them here will result in them being captured
by MailDev. Here's an example of using these with Nodemailer:

To pass parameters, because the Dockerfile uses CMD, you need to specify the executable again.
The Dockerfile specifically EXPOSES port 80 and 25, therefor you need to tell maildev to use them.
The Dockerfile specifically EXPOSES port 1080 and 1025, therefor you need to tell maildev to use them.
This example adds the base-pathname parameter.

```
$ docker run -p 1080:1080 -p 1025:1025 maildev/maildev bin/maildev --base-pathname /maildev -w 1080 -s 1025
```


```js
// We add this setting to tell nodemailer the host isn't secure during dev
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

const nodemailer = require('nodemailer')
const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
// In Node, environment variables are available on process.env
host: process.env.MAILDEV_PORT_25_TCP_ADDR, // ex. 172.17.0.10
port: process.env.MAILDEV_PORT_25_TCP_PORT, // ex. 25
})
port: process.env.MAILDEV_PORT_25_TCP_PORT, // ex. 1025
});

// Now when your send an email, it will show up in the MailDev interface
transporter.sendMail({ /* from, to, etc... */ }, (err, info) => { /* ... */ });
transporter.sendMail(
{
/* from, to, etc... */
},
(err, info) => {
/* ... */
}
);
```

The above example could apply for any app in any language using the available
environment variables to configure how to send email.

## Advanced usage

*Needs documentation for how to use cli arguments*
_Needs documentation for how to use cli arguments_

## Docker Compose

To use MailDev with Docker Compose, add the following to your
`docker-compose.yml` file in the `services` section:

```yaml
maildev:
image: maildev/maildev
ports:
- "1080:80"
maildev:
image: maildev/maildev
ports:
- "1080:1080"
```

Here's an example using Nodemailer:
Expand All @@ -84,15 +94,22 @@ Here's an example using Nodemailer:
// We add this setting to tell nodemailer the host isn't secure during dev
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

const nodemailer = require('nodemailer');
const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
host: 'maildev',
port: 25,
host: "maildev",
port: 1025,
});

// Now when your send an email, it will show up in the MailDev interface
transporter.sendMail({ /* from, to, etc... */ }, (err, info) => { /* ... */ });
transporter.sendMail(
{
/* from, to, etc... */
},
(err, info) => {
/* ... */
}
);
```

Note that the host name, `maildev`, is the name of the service in your
Expand Down

0 comments on commit f4d2f7e

Please sign in to comment.