# Send emails with Nextcloud

> Point Nextcloud's email server at PostShiba.

## What you'll build

A self-hosted Nextcloud server that sends its password resets, share notifications, and activity emails through PostShiba over SMTP.

## Before you start

- A **Transactional** cluster. Server notification mail belongs on a transactional cluster, and the type is locked after create. See [Clusters](/docs/dashboard/clusters/introduction).
- An SMTP username and password. Open your cluster in the dashboard, go to its SMTP credentials, and choose **Create SMTP credential**. Copy the password right away, because it is shown once. You can also use the [SMTP credentials API](/docs/api-reference/smtp-credentials).
- A verified sending domain. See [Add and verify a domain](/docs/add-a-domain). The From address must be on it.
- A cluster that is ready to send (`sending_ready` is `true`).
- A Nextcloud admin account with an email address saved in its personal settings. The test email goes there.

## Install

Nothing to install. Nextcloud has SMTP support built in.

## Send your first email

1. Sign in as an admin. Open the avatar menu, then **Administration settings** → **Basic settings**, and find **Email server**.
2. Set **Send mode** to **SMTP** and **Encryption** to **None / STARTTLS**. Nextcloud upgrades the connection with STARTTLS on port 587. Do not pick **SSL/TLS**, because it is for port 465. Leave **Disable certificate verification (insecure)** unchecked.
3. Under **From address**, put the part before the `@` in **Email** and your verified domain in **Domain**.
4. Under **Server address**, set **Host** to `smtp.postshiba.com` and **Port** to `587`.
5. Under **Authentication**, check **Authentication required**. Set **Login** to your username, which starts with `smtp_`, and **Password** to your password.
6. Select **Save settings**, then **Send test email**. Before Nextcloud 33, the button is **Send email**. The message shows under Events in the PostShiba dashboard.

The form writes these keys to `config/config.php`. You can set them there instead. `mail_from_address` is only the part before the `@`, and `mail_domain` is the part after it. An empty `mail_smtpsecure` means STARTTLS when the server offers it.

```php config.php
'mail_smtpmode' => 'smtp',
'mail_smtphost' => 'smtp.postshiba.com',
'mail_smtpport' => 587,
'mail_smtpsecure' => '',
'mail_smtpauth' => true,
'mail_smtpname' => 'smtp_9',
'mail_smtppassword' => 'YOUR_PASSWORD',
'mail_from_address' => 'hello',
'mail_domain' => 'mail.example.com',
```

You can also set each key with `occ config:system:set`, for example `occ config:system:set mail_smtpport --value=587 --type=integer`.

There is no setting for the authentication method. Nextcloud picks one that the server offers. Every SMTP setting is on [Send emails with SMTP](/docs/send-with-smtp).

## Troubleshooting

Nextcloud's Activity app sends activity emails and digests from background jobs, so a server with many users can send a lot of mail in a short time. Size the cluster so its hourly and 24-hour caps cover it. When a cap is full, SMTP answers `451 4.7.0 hourly send limit reached` or `451 4.7.0 daily send limit reached` and does not keep the message. See [What happens at your cap](/docs/dashboard/clusters/what-happens-at-your-cap).

To see the full SMTP reply, set `'mail_smtpdebug' => true` and `'loglevel' => 0` in `config/config.php`, send the test again, and read the Nextcloud log. Set them back to `false` and `2` when you are done.

| What you see in the Nextcloud log | What to do |
| --- | --- |
| Authentication fails | Check **Login** and **Password**, and check that **Authentication required** is on. PostShiba accepts `AUTH PLAIN` only. |
| The connection fails or times out | Check that **Port** is `587` and **Encryption** is **None / STARTTLS**. Port 465 with **SSL/TLS** is not offered. |
| `550 unverified domain` or `550 from header not aligned with verified domain` | Set **Domain** under **From address** to your verified domain. Without it, Nextcloud uses the server's own hostname. |
| `550 domain_suspended` | The From domain is paused. Resume it from [Managing domains](/docs/dashboard/domains/manage-domains). |
| `550 kyc_required` | Your team is pending production approval. Until then, send only to team members, live inbox addresses, and inbox forward-to addresses. See [Does PostShiba require production approval?](/docs/knowledge-base/does-capsule-require-production-approval). |
| `550 suppressed` or `550 firewall: <rule>` | The recipient is on the [suppression list](/docs/dashboard/emails/email-suppressions) or failed an [email firewall](/docs/dashboard/emails/email-firewall) check. PostShiba suppresses addresses that hard bounce or report spam. |
| `451 4.7.0 hourly send limit reached` or `451 4.7.0 daily send limit reached` | The cluster is at its cap and did not keep the message. Retry later, or resize the cluster. |

## Next steps

- [What happens at your cap](/docs/dashboard/clusters/what-happens-at-your-cap)
- [How to manage suppressions](/docs/dashboard/emails/email-suppressions)
- [Send emails with SMTP](/docs/send-with-smtp) for every setting and reply.
- [Managing webhooks](/docs/webhooks/introduction) to receive delivery events.
