# Incoming mail has stopped working
# Symptoms

1. SMTP email forwarding is set up from an address like `support@company.tld` -> `support@support.company.tld`, where company.tld is an email server (e.g., Gmail, VK, Yandex, or local), and support.company.tld is Swarmica.
2. Emails do not reach the ticket.
3. If you check the email box `support@company.tld`, the emails are there.
4. The sender's mail has bounces:
 Delivery Status Notification (Delay)
 454 4.7.1 : Relay access denied
5. The postfix logs on the server show errors like:
 `Oct 02 19:04:42 support postfix/smtpd[147]: NOQUEUE: reject: RCPT from unknown[79.137.243.76]: 454 4.7.1 <support@support.swarmica.com>: Relay access denied; from=<msudyin@swarmica.com> to=<support@support.swarmica.com> proto=ESMTP helo=<fallback20.i.mail.ru>`

# Solution

Add the IP addresses of the email provider (for example, [Gmail IP addresses](https://support.google.com/a/answer/60764?hl=en)) to the SMTP_NETWORKS variable and restart postfix:

```txt
vim .env
grep SMTP_NETWORKS .env
SMTP_NETWORKS=35.190.247.0/24,64.233.160.0/19,66.102.0.0/20,66.249.80.0/20,72.14.192.0/18,74.125.0.0/16,108.177.8.0/21,173.194.0.0/16,209.85.128.0/17,216.58.192.0/19,216.239.32.0/19,2001:4860:4000::/36,2404:6800:4000::/36,2607:f8b0:4000::/36,2800:3f0:4000::/36,2a00:1450:4000::/36,2c0f:fb50:4000::/36,172.217.0.0/19,172.217.32.0/20,172.217.128.0/19,172.217.160.0/20,172.217.192.0/19,172.253.56.0/21,172.253.112.0/20,108.177.96.0/19,35.191.0.0/16,130.211.0.0/22
docker-compose up -d
```

**WARNING! THIS COMMAND WILL RESTART ALL APPLICATIONS - THERE WILL BE DOWN TIME**

# Cause

Incoming mail is handled by postfix, which by default does not allow connections from external IP addresses

## For other providers

This error can also occur for other providers. For example, for VK Workspace, you need to set up SMTP_NETWORKS like this:

```txt
79.137.243.0/24,94.100.180.215/32,94.100.180.216/32,217.69.139.215/32,217.69.139.216/32
```

In general, you need to look at the SPF record of the domain **from which** the redirection is set up and add these servers