Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
16297da2
Unverified
Commit
16297da2
authored
May 13, 2020
by
thameezb
Committed by
GitHub
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Email Notifications: Add StartTLSPolicy config flag (#24574)
parent
285ea759
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
0 deletions
+20
-0
conf/defaults.ini
+1
-0
conf/sample.ini
+2
-0
docs/sources/installation/configuration.md
+3
-0
pkg/services/notifications/mailer.go
+12
-0
pkg/setting/setting_smtp.go
+2
-0
No files found.
conf/defaults.ini
View file @
16297da2
...
...
@@ -464,6 +464,7 @@ skip_verify = false
from_address
=
admin@grafana.localhost
from_name
=
Grafana
ehlo_identity
=
startTLS_policy
=
[emails]
welcome_email_on_sign_up
=
false
...
...
conf/sample.ini
View file @
16297da2
...
...
@@ -454,6 +454,8 @@
;from_name = Grafana
# EHLO identity in SMTP dialog (defaults to instance_name)
;ehlo_identity = dashboard.example.com
# SMTP startTLS policy (defaults to 'OpportunisticStartTLS')
;startTLS_policy = NoStartTLS
[emails]
;welcome_email_on_sign_up = false
...
...
docs/sources/installation/configuration.md
View file @
16297da2
...
...
@@ -560,6 +560,9 @@ Name to be used when sending out emails, defaults to `Grafana`
### ehlo_identity
Name to be used as client identity for EHLO in SMTP dialog, defaults to instance_name.
### startTLS_policy
Either "OpportunisticStartTLS", "MandatoryStartTLS", "NoStartTLS". Default is "OpportunisticStartTLS"
## [log]
### mode
...
...
pkg/services/notifications/mailer.go
View file @
16297da2
...
...
@@ -111,6 +111,7 @@ func (ns *NotificationService) createDialer() (*gomail.Dialer, error) {
d
:=
gomail
.
NewDialer
(
host
,
iPort
,
ns
.
Cfg
.
Smtp
.
User
,
ns
.
Cfg
.
Smtp
.
Password
)
d
.
TLSConfig
=
tlsconfig
d
.
StartTLSPolicy
=
getStartTLSPolicy
(
ns
.
Cfg
.
Smtp
.
StartTLSPolicy
)
if
ns
.
Cfg
.
Smtp
.
EhloIdentity
!=
""
{
d
.
LocalName
=
ns
.
Cfg
.
Smtp
.
EhloIdentity
...
...
@@ -120,6 +121,17 @@ func (ns *NotificationService) createDialer() (*gomail.Dialer, error) {
return
d
,
nil
}
func
getStartTLSPolicy
(
policy
string
)
gomail
.
StartTLSPolicy
{
switch
policy
{
case
"NoStartTLS"
:
return
-
1
case
"MandatoryStartTLS"
:
return
1
default
:
return
0
}
}
func
(
ns
*
NotificationService
)
buildEmailMessage
(
cmd
*
models
.
SendEmailCommand
)
(
*
Message
,
error
)
{
if
!
ns
.
Cfg
.
Smtp
.
Enabled
{
return
nil
,
models
.
ErrSmtpNotEnabled
...
...
pkg/setting/setting_smtp.go
View file @
16297da2
...
...
@@ -10,6 +10,7 @@ type SmtpSettings struct {
FromAddress
string
FromName
string
EhloIdentity
string
StartTLSPolicy
string
SkipVerify
bool
SendWelcomeEmailOnSignUp
bool
...
...
@@ -27,6 +28,7 @@ func (cfg *Cfg) readSmtpSettings() {
cfg
.
Smtp
.
FromAddress
=
sec
.
Key
(
"from_address"
)
.
String
()
cfg
.
Smtp
.
FromName
=
sec
.
Key
(
"from_name"
)
.
String
()
cfg
.
Smtp
.
EhloIdentity
=
sec
.
Key
(
"ehlo_identity"
)
.
String
()
cfg
.
Smtp
.
StartTLSPolicy
=
sec
.
Key
(
"startTLS_policy"
)
.
String
()
cfg
.
Smtp
.
SkipVerify
=
sec
.
Key
(
"skip_verify"
)
.
MustBool
(
false
)
emails
:=
cfg
.
Raw
.
Section
(
"emails"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment