# Mailpiece with Mailgun

*Send your newsletter through Mailgun's SMTP servers.*

Mailpiece sends every issue through Mailgun's SMTP with a domain's SMTP login.

## What you get

- Issues, test issues, welcome emails and confirmations
- US and EU regions: use the host of the region your domain lives in
- Each newsletter's own from name, from address and reply-to
- The app's sign-in mail through the same Mailgun domain
- Prefer its API? [Send through a relay](https://mailpiece.dev/docs/relay).

## Set up Mailgun

Verify your sending domain and note its region. Under Sending › Domain Settings › SMTP Credentials, add a login: an address on that domain, with its own password (not your API key).

## Set the outgoing mail

On Settings › Outgoing mail, set up an SMTP server: the Server is `smtp.mailgun.org` for a US domain or `smtp.eu.mailgun.org` for EU, the Port `587`, and the Username and Password your SMTP login, such as `newsletter@mg.example.com`. Port `587` uses STARTTLS; port `465` is TLS from the first byte.

```sh
# Or from the CLI; smtp.eu.mailgun.org for EU
mailpiece settings sending smtp update --address smtp.mailgun.org --port 587 \
  --username newsletter@mg.example.com --password ...

# The app's sign-in mail, optional: the same values
SMTP_ADDRESS=smtp.mailgun.org
SMTP_USERNAME=newsletter@mg.example.com
SMTP_PASSWORD=...
```

## Send a test issue

Set a from address on your verified domain in Settings › Sending and send a test issue from any post. If it does not arrive, check the domain's sending logs in Mailgun.

## Set it up this afternoon

Install Mailpiece on a server, connect Mailgun, and send your next issue. [Install Mailpiece](https://mailpiece.dev/docs/install)
