I am trying to send email via alertmanager using credential configured in config.yml file.
I am able to send mail via gmail smtp server using port 587.
But in realtime my customer is using 465 port and I am getting below error
"first record does not look like a tls handshake"
Below is my config file
route:
receiver: 'notifications-configuration'
#This receiver name can be any userdefined name
templates:
- '/etc/alertmanager/template/emailnotification.tmpl'
#Send the notifications to below receivers.
#There can be single as well as multiple receivers
#Here there are 2 receivers one is for mail and another is for sending notifications to some API provided
receivers:
- name: 'notifications-configuration'
email_configs:
- from: 'samplemailfrom@gmail.com'
auth_username: samplemailfrom@gmail.com'
auth_password: 'fdsfsdfsdfsdssds'
smarthost: 'smtp.gmail.com:587'
auth_identity: 'samplemailfrom@gmail.com'
tls_config:
insecure_skip_verify: true
to: 'samplemailto@gmail.com'
When I change this smtp host to the the customersmtphost:465 I am getting above mentioned errors
I googled for this issue and Found many links but I am not able to figure it out what change should I do in config.yaml to make it work
Please help on the same.. Thanks in advance
TLDR: Port 465 is not supported by the library used in Alertmanager, use port 587.
Ports 465 and 587 do different things, per Google's docs:
Port for SSL: 465
Port for TLS/STARTTLS: 587
The SSL port uses a TLS connection from the get-go, whereas the STARTTLS port uses a plain connection that is then upgraded to TLS (see wiki on STARTTLS.
Alertmanager uses smtp.Sendmail which states:
SendMail connects to the server at addr, switches to TLS if possible
This means that only the STARTTLS method is available, it cannot handle plain TLS. This makes port 465 unusable with the default Go sendmail package and thus alertmanager. You must use port 587.