Hi Team,
I am using grafana 9.0.4 on the container and trying to configure the SMTP to send the alerts over email. For the same, i have passed the required field and created my own container from grafana 9.0.4 version. Below is the docker file I used to create my own grafana image.
FROM grafana/grafana:9.0.4
ENV GF_SMTP_ENABLED=true \
GF_SMTP_HOST=<my company SMTP server> \
GF_SMTP_FROM_ADDRESS=<my company email id> \
GF_SERVER_DOMAIN=<my application server hostname> \
GF_SMTP_FROM_NAME=<my company email ID name> \
GF_SMTP_USER=<username to authenticate with SMTP server> \
GF_SMTP_PASSWORD=<Password to authenticate with SMTP server> \
GF_SERVER_HTTP_PORT=3000
After creating the image I created the container. to test the SMTP, I have gone to alerting and contact points and created a new contact point with my company email ID to test the alert.
So when I send the test alert it’s failing to send the alert and shows me an error message that
Failed to send test alert: Failed to send a notification to email address: unencrypted connection. image as below.
And from container logs i see below logs,
logger=alerting.notifier.email t=2022-09-22T15:39:24.775014379Z level=error msg="Missing receiver"
logger=alerting.notifier.email t=2022-09-22T15:39:24.775115337Z level=error msg="Missing group labels"
logger=context traceID=00000000000000000000000000000000 userId=1 orgId=1 uname=admin t=2022-09-22T15:39:25.147177545Z level=info msg="Request Completed" method=POST path=/api/alertmanager/grafana/config/api/v1/receivers/test status=207 remote_addr=172.17.0.1 time_ms=394 duration=394.994208ms size=460 referer="http://localhost:3001/alerting/notifications/receivers/new?alertmanager=grafana" traceID=00000000000000000000000000000000
So anyone please guide me on how to resolve this problem?
Hi @SarvaBhowma,
Please add this line in your SMTP config as it might help:
GF_SMTP_SKIP_VERIFY=true
Also, when you define the parameter for GF_SMTP_HOST are you also defining the port as well for e.g.
GF_SMTP_HOST=localhost:25
Lastly, can you verify this for e.g. test the SMTP with telnet without using Grafana (adjust your firewall to allow it e.g. on port 25)
telnet localhost 25
and see if you get a EHLO response
Thank you for the message @usman.ahmad
I have added the GF_SMTP_SKIP_VERIFY=true in my docker file and built the container. However, i am still seeing same unencrypted connection error.
I have given my corporate SMTP server details (using 25 port). So I logged into the container and tested the connection with 25 and it worked fine. I think it’s a problem with how grafana is sending the data to the smtp server when I am using the credentials or my company active directory is strictly expecting a specific type of connection.
Do you think I should check about using an SMTP server with TLS and with 465 or 587 ports.?
Just to add more context,
when i don’t use username and password fields(like below), I am receiving the emails, but only when I am trying to give credentials to authenticate it’s giving this error(I checked credentials are working perfectly fine.)
GF_SMTP_USER
GF_SMTP_PASSWORD
Hi @SarvaBhowma,
So if the SMTP Server is configured to receive messages from secure ports e.g TLS then in your config for GF_SMTP_HOST
try to test it out with e.g. localhost:465 OR localhost:587
Also you can add this additional config parameter in your docker-compose as it might help further i.e.
GF_SMTP_EHLO_IDENTITY=mail.comanyname.com
I have encountered the exactly same issue.
Current Infra: I have remote server with no access to internet, where Grafana is hosted. Now I need to send alerts to my corporate network. I have setup and SMTP server and created a user init.
Grafana server: I have added smtp server details, port number, user name, password, from on Grafana config file.
Issue: “Failed to send test alert: Failed to send notification to email addresses: xyz@companydomain.com unencrypted connection”
Understanding: Grafana is trying to send email alert to target servers like Outlook, gmail etc but these service providers only accepts email with secured connections like TLS/SSL. As out Grafana server is not able to send alert with secured connection to target server we are encountering this issue.
Resolution: I have configured an SMTP relay locally on the server where Grafana is hosted. Make sure you add neccessary information related to actual SMTP server, port number, username and password etc. Follow this to setup SMTP relay locally: How to Install and Configure SMTP Server on Windows (phoenixnap.com)
Then you should be able to send alerts to corporate networks.
Please feel free to connect with me, if you need help in setting up SMTP server locally.