hassio-addons / addon-grafana

Grafana - Home Assistant Community Add-ons
https://addons.community
MIT License
213 stars 61 forks source link

Setting GF_FROM_ADDRESS does not seem to override the default email address, preventing authenticated emails from being sent #342

Closed cmsimike closed 1 year ago

cmsimike commented 1 year ago

Problem/Motivation

I'm trying to setup Grafana alerting. In testing out email functionality, email sending is failing due to this error:

Failed to send test alert.: failed to send notification to email addresses: mike@example.com: gomail: could not send email 1: 553 5.7.1 admin@grafana.localhost: Sender address rejected: not owned by user grafana@example.com

I have these config values in the Env Var section:

- name: GF_SMTP_ENABLED
  value: "true"
- name: GF_SMTP_HOST
  value: mail.example.com:587
- name: GF_SMTP_USER
  value: grafana@example.com
- name: GF_SMTP_PASSWORD
  value:  password
- name: GF_FROM_ADDRESS
  value:  grafana@example.com
- name: GF_SMTP_SKIP_VERIFY
  value: "true"

My understanding is that setting GF_FROM_ADDRESS should override the sending email. But that does not seem to be the case. This is further verified going into the logs:

[22:00:54] INFO: Setting GF_SMTP_ENABLED to true
[22:00:54] INFO: Setting GF_SMTP_HOST to mail.example.com:587
[22:00:54] INFO: Setting GF_SMTP_USER to grafana@example.com
[22:00:54] INFO: Setting GF_SMTP_PASSWORD to password
[22:00:54] INFO: Setting GF_FROM_ADDRESS to grafana@example.com
[22:00:54] INFO: Setting GF_SMTP_SKIP_VERIFY to true
Grafana server is running with elevated privileges. This is not recommended
logger=settings t=2023-07-17T22:00:54.870877028-07:00 level=info msg="Starting Grafana" version=10.0.2 commit=b2bbe10fbc branch=HEAD compiled=2023-06-30T01:34:22-07:00
logger=settings t=2023-07-17T22:00:54.871282792-07:00 level=warn msg="\"sentry\" frontend logging provider is deprecated and will be removed in the next major version. Use \"grafana\" provider instead."
logger=settings t=2023-07-17T22:00:54.871382749-07:00 level=info msg="Config loaded from" file=/usr/share/grafana/conf/defaults.ini
logger=settings t=2023-07-17T22:00:54.871422349-07:00 level=info msg="Config loaded from" file=/etc/grafana/grafana.ini
logger=settings t=2023-07-17T22:00:54.871465774-07:00 level=info msg="Config overridden from Environment variable" var="GF_SMTP_ENABLED=true"
logger=settings t=2023-07-17T22:00:54.871502243-07:00 level=info msg="Config overridden from Environment variable" var="GF_SMTP_HOST=mail.example.com:587"
logger=settings t=2023-07-17T22:00:54.87153857-07:00 level=info msg="Config overridden from Environment variable" var="GF_SMTP_USER=grafana@example.com"
logger=settings t=2023-07-17T22:00:54.871601803-07:00 level=info msg="Config overridden from Environment variable" var="GF_SMTP_PASSWORD=*********"
logger=settings t=2023-07-17T22:00:54.871642775-07:00 level=info msg="Config overridden from Environment variable" var="GF_SMTP_SKIP_VERIFY=true"

There is no "Config overridden from Environment variable" line for GF_FROM_ADDRESS

Expected behavior

I'd like the from email address to be overridden by env vrs.

Actual behavior

The email address still uses the default address.

Steps to reproduce

Configure an email address with authentication without an alias and try sending a test email.

Proposed changes

If someone specifies an GF_FROM_ADDRESS env var, that should override the default config value.

cmsimike commented 1 year ago

Should have been GF_SMTP_FROM_ADDRESS