Grafana Docker - Send Mails from localhost

What Grafana version and what operating system are you using?

Grafana 8.5.5 (docker) on a Debian 11 machine

What are you trying to achieve?

Enabling the docker container to send emails from the localhost without a relay or other SMTP server (such as Gmail).

How are you trying to achieve it?

Setting GF_SMTP_HOST=localhost:25 to my machine’s IP with port 25

What happened?

The container is blocked. When attempting to send a test alert, I get a connection refused.
This may have to do with my very strict firewall that only allows access to port 22 from the outside for security reasons. However, it seems the request does not even reach the firewall at least from what I could see in its logs.
I suspect that the container either uses its own localhost in the first case which does not have postfix or cannot be forwarded to the host by docker since it is not in the host network, or is blocked by the firewall in the second case.

What did you expect to happen?

The mail is sent using the machine’s postfix config, similar to what happens when I use sendmail on the host directly.

Can you copy/paste the configuration(s) that you are having problems with?


Did you receive any errors in the Grafana UI or related logs? If so, please tell us exactly what they were.

In the UI:

Failed to send test alert.: Failed to send notification to email addresses: dial tcp {,<host-ip>}:25: connect: connection refused

In the logs:

grafana_1        | level=error msg="Missing receiver"
grafana_1        | level=error msg="Missing group labels"
grafana_1        | logger=context traceID=00000000000000000000000000000000 userId=2 orgId=1 uname=<uid> t=<time> lvl=info msg="Request Completed" method=POST path=/api/alertmanager/grafana/config/api/v1/receivers/test status=207 remote_addr=<host-ip> time_ms=5 duration=5.698845ms size=477 referer="" traceID=00000000000000000000000000000000

Did you follow any online instructions? If so, what is the URL?


is there such an address?

Yes, it’s my personal address. I just replaced it here for the sake of privacy.